Servertec | Connection

Content Introduction Release Notes Features FAQs Requirements Installation Add-ons How To Change Log Future Plans Knowledge Base Documentation Conventions Users Reference iServer API AccessLogEntry Codecs Connection ConnectionPool... DString ErrorLogEntry EventLogEntry FileCache FileUpload IOHandler IOManager iws Logger MultiPartForm QuickSort Realm RealmAdmin... ServletManager Utils Servlet API CGI SSI Servlets Config Files Log Files Classes Directory Tree Samples Sales Legal Feedback |
    java.lang.Object
     |
     +--stec.sql.Connection
public class Connection extends Object 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.
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.
#### 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 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 void clearWarnings() 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 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 Statement createStatement() throws SQLException #### Parameters
None
#### 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 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 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 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 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() ### getWarnings Returns the first SQL warning. #### Syntax public 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 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 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 String nativeSQL(String sql) throws SQLException #### Parameters
sql | the SQL statement to convert.
#### Returns
String | the native form the 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 CallableStatement prepareCall(String sql) throws SQLException #### Parameters
sql | the SQL statement.
#### 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 PreparedStatement prepareStatement(String sql) throws SQLException #### Parameters
sql | the SQL statement.
#### 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 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 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 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 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 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);
top of page
| Copyright © 1997-2000 Servertec. All rights reserved. Last Modified: Sun Jan 09 19:34:12 EST 2000