|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.ibm.as400.access.AS400JDBCConnectionHandle
The AS400JDBCConnectionHandle class represents an AS400JDBCConnection object that can be used in a AS400JDBCPooledConnection.
Creating a handle to a connection object allows the connection to be reused. The connection handle acts like a normal Connection object and should be closed after an application is done using it so it can be reused.
The following example obtains a connection handle to a pooled connection.
// Create a data source for making the connection. AS400JDBCConnectionPoolDataSource dataSource = new AS400JDBCConnectionPoolDataSource("CheeseDataBase"); datasource.setServerName("myAS400"); datasource.setUser("Mickey Mouse"); datasource.setPassword("IAMNORAT"); // Get a PooledConnection and get the connection handle to the database. AS400JDBCPooledConnection pooledConnection = datasource.getPooledConnection(); Connection connection = pooledConnection.getConnection(); ... work with the handle as if it is a normal connection. // Close the connection handle to it make available again for reuse. connection.close();
| Field Summary |
| Fields inherited from interface java.sql.Connection |
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
| Method Summary | |
void |
clearWarnings()
Clears all warnings that have been reported for the connection. |
void |
close()
Closes the handle to the connection. |
void |
commit()
Commits all changes made since the previous commit or rollback and releases any database locks currently held by the connection. |
java.sql.Statement |
createStatement()
Creates a Statement object for executing SQL statements without parameters. |
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
Creates a Statement object for executing SQL statements without parameters. |
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a Statement object for executing SQL statements without parameters. |
protected void |
finalize()
Closes the connection if not explicitly closed by the caller. |
boolean |
getAutoCommit()
Returns the auto-commit state. |
java.lang.String |
getCatalog()
Returns the catalog name. |
int |
getHoldability()
Returns the holdability of ResultSets created from this connection. |
java.sql.DatabaseMetaData |
getMetaData()
Returns the DatabaseMetaData object that describes the connection's tables, supported SQL grammar, stored procedures, capabilities and more. |
java.lang.String |
getServerJobIdentifier()
Returns the job identifier of the host server job corresponding to this connection. |
int |
getTransactionIsolation()
Returns the transaction isolation level. |
java.util.Map |
getTypeMap()
Returns the type map. |
java.sql.SQLWarning |
getWarnings()
Returns the first warning reported for the connection. |
void |
invalidate()
Invalidates the connection. |
boolean |
isClosed()
Indicates if the connection is closed. |
boolean |
isReadOnly()
Indicates if the connection is in read-only mode. |
java.lang.String |
nativeSQL(java.lang.String sql)
Returns the native form of an SQL statement without executing it. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql)
Precompiles an SQL stored procedure call with optional input and output parameters and stores it in a CallableStatement object. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Precompiles an SQL stored procedure call with optional input and output parameters and stores it in a CallableStatement object. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Precompiles an SQL stored procedure call with optional input and output parameters and stores it in a CallableStatement object. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int[] columnIndexes)
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. |
void |
releaseSavepoint(java.sql.Savepoint savepoint)
Removes the given Savepoint object from the current transaction. |
void |
rollback()
Drops all changes made since the previous commit or rollback and releases any database locks currently held by the connection. |
void |
rollback(java.sql.Savepoint savepoint)
Undoes all changes made after the specified Savepoint was set. |
void |
setAutoCommit(boolean autoCommit)
Sets the auto-commit mode. |
void |
setCatalog(java.lang.String catalog)
This method is not supported. |
void |
setDB2eWLMCorrelator(byte[] bytes)
Sets the eWLM Correlator. |
void |
setHoldability(int holdability)
Sets the holdability of ResultSets created from this connection. |
void |
setReadOnly(boolean readOnly)
Sets the read-only mode. |
java.sql.Savepoint |
setSavepoint()
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it. |
java.sql.Savepoint |
setSavepoint(java.lang.String name)
Creates a named savepoint in the current transaction and returns the new Savepoint object that represents it. |
void |
setTransactionIsolation(int level)
Sets the transaction isolation level. |
void |
setTypeMap(java.util.Map typeMap)
Sets the type map to be used for distinct and structured types. |
java.lang.String |
toString()
Returns the connection's catalog name. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
public void clearWarnings()
throws java.sql.SQLException
clearWarnings in interface java.sql.Connectionjava.sql.SQLException - If an error occurs.
public void close()
throws java.sql.SQLException
close in interface java.sql.Connectionjava.sql.SQLException - If an error occurs.
public void commit()
throws java.sql.SQLException
commit in interface java.sql.Connectionjava.sql.SQLException - If the connection is not open
or an error occurs.
public java.sql.Statement createStatement()
throws java.sql.SQLException
Result sets created using the statement will be type ResultSet.TYPE_FORWARD_ONLY and concurrency ResultSet.CONCUR_READ_ONLY.
createStatement in interface java.sql.Connectionjava.sql.SQLException - If the connection is not open, the maximum number
of statements for this connection has been reached, or an error occured.
public java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
createStatement in interface java.sql.ConnectionresultSetType - The result set type. Valid values are:
resultSetConcurrency - The result set concurrency. Valid values are:
java.sql.SQLException - If the connection is not open, the maximum number of statements
for this connection has been reached, the result type or currency
is not supported, or an error occured.
public java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
Full functionality of this method requires support in OS/400 V5R2 or later. If connecting to a V5R1 or earlier version of OS/400, the value for resultSetHoldability will be ignored.
createStatement in interface java.sql.ConnectionresultSetType - The result set type. Valid values are:
resultSetConcurrency - The result set concurrency. Valid values are:
resultSetHoldability - The result set holdability. Valid values are:
java.sql.SQLException - If the connection is not open,
the maximum number of statements
for this connection has been reached, the
result type, currency, or holdability is not supported,
or an error occurs.
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable - If an error occurs.
public boolean getAutoCommit()
throws java.sql.SQLException
getAutoCommit in interface java.sql.Connectionjava.sql.SQLException - If the connection is not open.
public java.lang.String getCatalog()
throws java.sql.SQLException
getCatalog in interface java.sql.Connectionjava.sql.SQLException - If the connection is not open.
public int getHoldability()
throws java.sql.SQLException
getHoldability in interface java.sql.Connection cursor hold
driver property. java.sql.SQLException - If the connection is not open.
public java.sql.DatabaseMetaData getMetaData()
throws java.sql.SQLException
getMetaData in interface java.sql.Connectionjava.sql.SQLException - If an error occurs.
public java.lang.String getServerJobIdentifier()
throws java.sql.SQLException
Note: Since this method is not defined in the JDBC Connection interface, you typically need to cast a Connection object returned from PooledConnection.getConnection() to an AS400JDBCConnectionHandle in order to call this method:
String serverJobIdentifier = ((AS400JDBCConnectionHandle)connection).getServerJobIdentifier();
java.sql.SQLException - If the connection is not open.
public int getTransactionIsolation()
throws java.sql.SQLException
getTransactionIsolation in interface java.sql.Connectionjava.sql.SQLException - If the connection is not open.
public java.util.Map getTypeMap()
throws java.sql.SQLException
This driver does not support the type map.
getTypeMap in interface java.sql.Connectionjava.sql.SQLException - This exception is always thrown.
public java.sql.SQLWarning getWarnings()
throws java.sql.SQLException
getWarnings in interface java.sql.Connectionjava.sql.SQLException - If an error occurs.public void invalidate()
public boolean isClosed()
throws java.sql.SQLException
isClosed in interface java.sql.Connectionjava.sql.SQLException - If an error occurs.
public boolean isReadOnly()
throws java.sql.SQLException
isReadOnly in interface java.sql.Connectionjava.sql.SQLException - If the connection is not open.
public java.lang.String nativeSQL(java.lang.String sql)
throws java.sql.SQLException
nativeSQL in interface java.sql.Connectionsql - The SQL statement in terms of the JDBC SQL grammar.
java.sql.SQLException - If the SQL statement has a syntax error.
public java.sql.CallableStatement prepareCall(java.lang.String sql)
throws java.sql.SQLException
Result sets created using the statement will be type ResultSet.TYPE_FORWARD_ONLY and concurrency ResultSet.CONCUR_READ_ONLY.
prepareCall in interface java.sql.Connectionsql - The SQL stored procedure call.
java.sql.SQLException - If the connection is not open,
the maximum number of statements
for this connection has been reached, or an
error occurs.
public java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionsql - The SQL statement.resultSetType - The result set type. Valid values are:
resultSetConcurrency - The result set concurrency. Valid values are:
java.sql.SQLException - If the connection is not open, the maximum number of statements
for this connection has been reached, the result type or currency
is not valid, or an error occurs.
public java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
Full functionality of this method requires support in OS/400 V5R2 or later. If connecting to a V5R1 or earlier version of OS/400, the value for resultSetHoldability will be ignored.
prepareCall in interface java.sql.Connectionsql - The SQL statement.resultSetType - The result set type. Valid values are:
resultSetConcurrency - The result set concurrency. Valid values are:
resultSetHoldability - The result set holdability. Valid values are:
java.sql.SQLException - If the connection is not open,
the maximum number of statements
for this connection has been reached, the
result type, currency, or holdability is not valid,
or an error occurs.
public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
Result sets created using the statement will be type ResultSet.TYPE_FORWARD_ONLY and concurrency ResultSet.CONCUR_READ_ONLY.
prepareStatement in interface java.sql.Connectionsql - The SQL statement.
java.sql.SQLException - If the connection is not open,
the maximum number of statements
for this connection has been reached, or an
error occurs.
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
This method requires OS/400 V5R2 or later. If connecting to a V5R1 or earlier version of OS/400, an exception will be thrown.
Result sets created using the statement will be type ResultSet.TYPE_FORWARD_ONLY and concurrency ResultSet.CONCUR_READ_ONLY.
prepareStatement in interface java.sql.Connectionsql - The SQL statement.autoGeneratedKeys - Whether to return auto generated keys. Valid values are:
java.sql.SQLException - If the connection is not open,
the maximum number of statements
for this connection has been reached,
if connecting to a V5R1 or earlier version of OS/400,
or an error occurs.
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
This method is not supported. An SQLException is always thrown.
prepareStatement in interface java.sql.Connectionsql - The SQL statement.columnIndexes - An array of column indexes indicating the columns that should be returned from the inserted row or rows.
java.sql.SQLException - - Always thrown because the Toolbox JDBC driver does does not support this method.
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - The SQL statement.resultSetType - The result set type. Valid values are:
resultSetConcurrency - The result set concurrency. Valid values are:
java.sql.SQLException - If the connection is not open,
the maximum number of statements
for this connection has been reached, the
result type or currency is not valid,
or an error occurs.
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - The SQL statement.resultSetType - The result set type. Valid values are:
resultSetConcurrency - The result set concurrency. Valid values are:
resultSetHoldability - The result set holdability. Valid values are:
java.sql.SQLException - If the connection is not open,
the maximum number of statements
for this connection has been reached, the
result type, currency, or holdability is not valid,
or an error occurs.
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
This method is not supported. An SQLException is always thrown.
prepareStatement in interface java.sql.Connectionsql - The SQL statement.columnNames - An array of column names indicating the columns that should be returned from the inserted row or rows.
java.sql.SQLException - - Always thrown because the Toolbox JDBC driver does does not support this method.
public void releaseSavepoint(java.sql.Savepoint savepoint)
throws java.sql.SQLException
releaseSavepoint in interface java.sql.Connectionsavepoint - the savepoint to be removed.
java.sql.SQLException - if a database access error occurs or the given Savepoint
is not a valid savepoint in the current transaction.
public void rollback()
throws java.sql.SQLException
rollback in interface java.sql.Connectionjava.sql.SQLException - If the connection is not open
or an error occurs.
public void rollback(java.sql.Savepoint savepoint)
throws java.sql.SQLException
rollback in interface java.sql.Connectionsavepoint - the savepoint to be rolled back to.
java.sql.SQLException - if a database access error occurs, the Savepoint
is no longer valid, or this Connection
is currently in auto-commit mode.
public void setAutoCommit(boolean autoCommit)
throws java.sql.SQLException
By default, the connection is in auto-commit mode. The commit occurs when the statement execution completes or the next statement execute occurs, whichever comes first. In the case of statements returning a result set, the statement execution completes when the last row of the result set has been retrieved or the result set has been closed. In advanced cases, a single statement may return multiple results as well as output parameter values. Here the commit occurs when all results and output parameter values have been retrieved.
setAutoCommit in interface java.sql.ConnectionautoCommit - true to turn on auto-commit mode, false to
turn it off.
java.sql.SQLException - If the connection is not open
or an error occurs.
public void setDB2eWLMCorrelator(byte[] bytes)
throws java.sql.SQLException
bytes - The eWLM correlator value
java.sql.SQLException
public void setCatalog(java.lang.String catalog)
throws java.sql.SQLException
setCatalog in interface java.sql.Connectionjava.sql.SQLException - If the connection is not open.
public void setHoldability(int holdability)
throws java.sql.SQLException
Full functionality of this method requires OS/400 V5R2 or later. If connecting to a V5R1 or earlier version of OS/400, all cursors for the connection will be changed to the value of the variable holdability.
setHoldability in interface java.sql.Connectionholdability - The cursor holdability.
Valid values are ResultSet.HOLD_CURSORS_OVER_COMMIT or
ResultSet.CLOSE_CURSORS_AT_COMMIT.
java.sql.SQLException - If the connection is not open
or the value passed in is not valid.
public void setReadOnly(boolean readOnly)
throws java.sql.SQLException
setReadOnly in interface java.sql.ConnectionreadOnly - true to set the connection to read-only mode;
false to set the connection to read-write mode.
java.sql.SQLException - If the connection is not open,
a transaction is active, or the
"access" property is set to "read
only".
public java.sql.Savepoint setSavepoint()
throws java.sql.SQLException
setSavepoint in interface java.sql.Connectionjava.sql.SQLException - if a database access error occurs or this Connection object is currently in auto-commit mode.
public java.sql.Savepoint setSavepoint(java.lang.String name)
throws java.sql.SQLException
setSavepoint in interface java.sql.Connectionname - A String containing the name of the savepoint
java.sql.SQLException - if a database access error occurs or this Connection object is currently in auto-commit mode.
public void setTransactionIsolation(int level)
throws java.sql.SQLException
JDBC and DB2 UDB for iSeries use different terminology for transaction isolation levels. The following table provides a terminology mapping:
| AS/400 or iSeries isolation level | JDBC transaction isolation level |
|---|---|
| *CHG | TRANSACTION_READ_UNCOMMITTED |
| *CS | TRANSACTION_READ_COMMITTED |
| *ALL | TRANSACTION_READ_REPEATABLE_READ |
| *RR | TRANSACTION_SERIALIZABLE |
setTransactionIsolation in interface java.sql.Connectionlevel - The transaction isolation level. Possible values are:
java.sql.SQLException - If the connection is not open, the input level is not valid
or unsupported, or a transaction is active.
public void setTypeMap(java.util.Map typeMap)
throws java.sql.SQLException
Note: Distinct types are supported by DB2 UDB for iSeries, but are not externalized by the IBM Toolbox for Java JDBC driver. In other words, distinct types behave as if they are the underlying type. Structured types are not supported by DB2 UDB for iSeries. Consequently, this driver does not support the type map.
setTypeMap in interface java.sql.ConnectiontypeMap - The type map.
java.sql.SQLException - This exception is always thrown.public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||