Servertec Connection
Content
Introduction
Release Notes
Features
FAQs
Requirements
Installation
Add-ons
How To
Change Log
Future Plans
Knowledge Base
Documentation
Conventions
Command Line
Administrator
Localization
Programming
Security
Performance
Deployment
Java API
AccessLogEntry
Codecs
Connection
ConnectionPool...
DString
ErrorLogEntry
EventLogEntry
FileCache
FileUpload
IOHandler
IOManager
iws
Logger
MonitorEvent...
MultiPartForm
QuickSort
Realm
RealmAdmin...
RealmManager
ServletContextImpl
ServletContext...
ServletImpl
ServletManager
SocketHandler
Utils

Servlet API
CGI
SSI
Servlets
Config Files
Log Files
Classes
Directory Tree
Samples
Legal
Contact Us

 

java.lang.Object
 |
 +--stec.sql.Connection

public final class Connection implements java.sql.Connection

A session to a specific database used to execute SQL statements.

Fields

Field Description
TRANSACTION_NONE Transactions are not supported.
TRANSACTION_READ_COMMITTED Prevent dirty reads. Allow non-repeatable reads and phantom reads.
TRANSACTION_READ_UNCOMMITTED Allow dirty reads, non-repeatable reads and phantom reads.
TRANSACTION_REPEATABLE_READ Prevent dirty reads and non-repeatable reads. Allow phantom reads.
TRANSACTION_SERIALIZABLE Prevent dirty reads, non-repeatable reads and phantom reads.

Methods

Method Description
clearWarnings Clears all warnings.
close Returns this connection to the connection pool.
commit Makes all changes made since the last commit/rollback permanent and releases any locks held.
createStatement Returns a new SQL Statement object.
getAutoCommit Gets the current state of auto-commit.
getCatalog Returns current catalog name.
getMetaData Returns the database meta data.
getTransactionIsolation Returns the current transaction isolation level.
getTypeMap Returns the current Map object used to map custom SQL types.
getWarnings Returns the first warning.
isClosed Returns whether this connection was returned to the connection pool.
isReadOnly Returns whether in read-only mode.
nativeSQL Returns the native form of the given SQL statement.
prepareCall Creates a CallableStatement object from the given SQL statement for calling database stored procedures.
prepareStatement Creates a PreparedStatement object from the given parameterized SQL statement.
rollback Rolls back all changes made since the last commit/rollback and releases any locks held.
setAutoCommit Sets the auto-commit mode.
setCatalog Sets the catalog name.
setReadOnly Sets the read-only mode.
setTransactionIsolation Sets the transaction isolation level.
setTypeMap Sets the Map object used to map custom SQL types.

Notes

Unless auto-commit mode has been disabled, a connection automatically commits changes after each statement. If auto-commit mode has been disabled, a commit must be done or changes to the database will not be made.

TRANSACTION_NONE

Transactions are not supported.

Syntax

public static final int TRANSACTION_NONE

Example

int level = Connection.TRANSACTION_NONE;

TRANSACTION_READ_COMMITTED

Prevent dirty reads. Allow non-repeatable reads and phantom reads.

Syntax

public static final int TRANSACTION_READ_COMMITTED

Example

int level = Connection.TRANSACTION_READ_COMMITTED;

TRANSACTION_READ_UNCOMMITTED

Allow dirty reads, non-repeatable reads and phantom reads.

Syntax

public static final int TRANSACTION_READ_UNCOMMITTED

Example

int level = Connection.TRANSACTION_READ_UNCOMMITTED;

TRANSACTION_REPEATABLE_READ

Prevent dirty reads and non-repeatable reads. Allow phantom reads.

Syntax

public static final int TRANSACTION_REPEATABLE_READ

Example

int level = Connection.TRANSACTION_REPEATABLE_READ;

TRANSACTION_SERIALIZABLE

Prevent dirty reads, non-repeatable reads and phantom reads.

Syntax

public static final int TRANSACTION_SERIALIZABLE

Example

int level = Connection.TRANSACTION_SERIALIZABLE;

clearWarnings

Clears all warnings.

Syntax

public final void clearWarnings() throws SQLException

Parameters

None

Returns

Nothing

Throws

SQLException if a database access error occurs.

Example

con.clearWarnings();

close

Returns this connection to the connection pool.

Syntax

public final void close() throws SQLException

Parameters

None

Returns

Nothing

Throws

SQLException if a database access error occurs.

Example

con.close();

commit

Makes all changes made since the last commit/rollback permanent and releases any locks held.

Syntax

public final void commit() throws SQLException

Parameters

None

Returns

Nothing

Throws

SQLException if a database access error occurs.

Example

con.commit();

createStatement

Returns a new SQL Statement object.

Syntax

public final Statement createStatement()
                                       throws SQLException
public final Statement createStatement(int type, int concurrency) throws SQLException

Parameters

type the ResultSet type, ResultSet.TYPE_type.
concurrency the ResultSet concurrency type, ResultSet.CONCUR_concurrency.

Returns

Statement a new SQL Statement object.

Throws

SQLException if a database access error occurs.

Example

Statement stmt = con.createStatement();

getAutoCommit

Gets the current state of auto-commit.

Syntax

public final boolean getAutoCommit() throws SQLException

Parameters

None

Returns

boolean true if in auto-commit mode, false if not.

Throws

SQLException if a database access error occurs.

Example

if(!con.getAutoCommit()) con.commit()

getCatalog

Returns current catalog name.

Syntax

public final String getCatalog() throws SQLException

Parameters

None

Returns

String the current catalog name, null if none.

Throws

SQLException if a database access error occurs.

Example

catalog = con.getCatalog()

getMetaData

Returns the database meta data.

Syntax

public final DatabaseMetaData getMetaData() throws SQLException

Parameters

None

Returns

DatabaseMetaData a DatabaseMetaData object.

Throws

SQLException if a database access error occurs.

Example

DatabaseMetaData metadata = con.getMetaData()

getTransactionIsolation

Returns the current transaction isolation level.

Syntax

public final int getTransactionIsolation() throws SQLException

Parameters

None

Returns

int the current transaction isolation level.

Throws

SQLException if a database access error occurs.

Example

int level = con.getTransactionIsolation()

getTypeMap

Returns the current Map object used to map custom SQL types.

Syntax

public final Map getTypeMap() throws SQLException

Parameters

None

Returns

Map the current Map object used to map custom SQL types.

Throws

SQLException if a database access error occurs.

Example

Map map = con.getTypeMap()

getWarnings

Returns the first SQL warning.

Syntax

public final SQLWarning getWarnings() throws SQLException

Parameters

None

Returns

SQLWarning the first SQLWarning, null if none.

Throws

SQLException if a database access error occurs.

Example

SQLWarning warning = con.getWarnings()

isClosed

Returns whether this connection was returned to the connection pool.

Syntax

public final boolean isClosed() throws SQLException

Parameters

None

Returns

boolean true if the connection was returned to the connection pool, false if not.

Throws

SQLException if a database access error occurs.

Example

if(!con.isClosed()) con.close()

isReadOnly

Returns whether in read-only mode.

Syntax

public final boolean isReadOnly() throws SQLException

Parameters

None

Returns

boolean true if in read-only mode, false if not.

Throws

SQLException if a database access error occurs.

Example

if(!con.isReadOnly()) update(con, record);

nativeSQL

Returns the native form of the given SQL statement.

Syntax

public final String nativeSQL(String sql) throws SQLException

Parameters

sql the SQL statement to convert.

Returns

String the native form of the specified SQL statement.

Throws

SQLException if a database access error occurs.

Example

String native = con.nativeSQL(sql);

prepareCall

Creates a CallableStatement object from the given SQL statement for calling database stored procedures.

Syntax

public final CallableStatement prepareCall(String sql)
                                           throws SQLException

public final CallableStatement prepareCall(String sql,
                                           int type,
                                           int concurrency)
                                           throws SQLException

Parameters

sql the SQL statement.
type the ResultSet type, ResultSet.TYPE_type.
concurrency the ResultSet concurrency type, ResultSet.CONCUR_concurrency.

Returns

CallableStatement a new CallableStatement object.

Throws

SQLException if a database access error occurs.

Example

CallableStatement stmt = con.prepareCall(sql);

prepareStatement

Creates a PreparedStatement object from the given parameterized SQL statement.

Syntax

public final PreparedStatement prepareStatement(String sql)
    throws SQLException

public final PreparedStatement prepareStatement(String sql,
    int type,
    int concurrency)
    throws SQLException

Parameters

sql the SQL statement.
type the ResultSet type, ResultSet.TYPE_type.
concurrency the ResultSet concurrency type, ResultSet.CONCUR_concurrency.

Returns

PreparedStatement a new PreparedStatement object.

Throws

SQLException if a database access error occurs.

Example

PreparedStatement stmt = con.prepareStatement(sql);

rollback

Rolls back all changes made since the last commit/rollback and releases any locks held.

Syntax

public final void rollback() throws SQLException

Parameters

None

Returns

Nothing

Throws

SQLException if a database access error occurs.

Example

con.rollback();

setAutoCommit

Sets the auto-commit mode.

Syntax

public final void setAutoCommit(boolean autoCommit)
                                throws SQLException

Parameters

autoCommit true to enable auto-commit mode, false to disable auto-commit mode.

Returns

Nothing

Throws

SQLException if a database access error occurs.

Example

con.setAutoCommit(true);

setCatalog

Sets the catalog name.

Syntax

public final void setCatalog(String catalog)
                             throws SQLException

Parameters

catalog the catalog's name.

Returns

Nothing

Throws

SQLException if a database access error occurs.

Example

con.setCatalog(catalog);

setReadOnly

Sets the read-only mode.

Syntax

public final void setReadOnly(boolean readOnly)
                              throws SQLException

Parameters

readOnly true to enable read-only mode, false to disable read-only mode.

Returns

Nothing

Throws

SQLException if a database access error occurs.

Example

con.setReadOnly(true);

setTransactionIsolation

Sets the transaction isolation level.

Syntax

public final void setTransactionIsolation(int level)
                                          throws SQLException

Parameters

level the transaction isolation level.

Returns

Nothing

Throws

SQLException if a database access error occurs.

Example

con.setTransactionIsolation(level);

setTypeMap

Sets the Map object used to map custom SQL types.

Syntax

public final void setTypeMap(Map typemap) throws SQLException

Parameters

typemap the Map object used to map custom SQL types.

Returns

Nothing

Throws

SQLException if a database access error occurs.

Example

con.setTypeMap(typemap);
 top of page
Copyright © 1998-2005 Servertec. All rights reserved.
Privacy Statement.
Last Modified: Sun Sep 04 14:56:49 EDT 2005