com.ibm.as400.access
Class AS400JDBCConnectionHandle

java.lang.Object
  extended bycom.ibm.as400.access.AS400JDBCConnectionHandle
All Implemented Interfaces:
Connection

public class AS400JDBCConnectionHandle
extends Object
implements Connection

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.
 Statement createStatement()
          Creates a Statement object for executing SQL statements without parameters.
 Statement createStatement(int resultSetType, int resultSetConcurrency)
          Creates a Statement object for executing SQL statements without parameters.
 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.
 String getCatalog()
          Returns the catalog name.
 Properties getClientInfo()
          Returns a list containing the name and current value of each client info property supported by the driver.
 String getClientInfo(String name)
          Returns the value of the client info property specified by name.
 int getHoldability()
          Returns the holdability of ResultSets created from this connection.
 DatabaseMetaData getMetaData()
          Returns the DatabaseMetaData object that describes the connection's tables, supported SQL grammar, stored procedures, capabilities and more.
 String getServerJobIdentifier()
          Returns the job identifier of the host server job corresponding to this connection.
 int getTransactionIsolation()
          Returns the transaction isolation level.
 Map getTypeMap()
          Returns the type map.
 SQLWarning getWarnings()
          Returns the first warning reported for the connection.
 boolean isClosed()
          Indicates if the connection is closed.
 boolean isReadOnly()
          Indicates if the connection is in read-only mode.
 String nativeSQL(String sql)
          Returns the native form of an SQL statement without executing it.
 CallableStatement prepareCall(String sql)
          Precompiles an SQL stored procedure call with optional input and output parameters and stores it in a CallableStatement object.
 CallableStatement prepareCall(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.
 CallableStatement prepareCall(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.
 PreparedStatement prepareStatement(String sql)
          Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object.
 PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
          Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object.
 PreparedStatement prepareStatement(String sql, int[] columnIndexes)
          Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object.
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
          Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object.
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object.
 PreparedStatement prepareStatement(String sql, String[] columnNames)
          Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object.
 void releaseSavepoint(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(Savepoint savepoint)
          Undoes all changes made after the specified Savepoint was set.
 void setAutoCommit(boolean autoCommit)
          Sets the auto-commit mode.
 void setCatalog(String catalog)
          This method is not supported.
 void setClientInfo(Properties properties)
          Sets the value of the connection's client info properties.
 void setClientInfo(String name, String value)
          Sets the value of the client info property specified by name to the value specified by value.
 void setDB2eWLMCorrelator(byte[] bytes)
          Sets the eWLM Correlator.
 void setDBHostServerTrace(boolean trace)
          Starts or stops the Database Host Server trace for this connection.
 void setHoldability(int holdability)
          Sets the holdability of ResultSets created from this connection.
 void setReadOnly(boolean readOnly)
          Sets the read-only mode.
 Savepoint setSavepoint()
          Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.
 Savepoint setSavepoint(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(Map typeMap)
          Sets the type map to be used for distinct and structured types.
 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

clearWarnings

public void clearWarnings()
                   throws SQLException
Clears all warnings that have been reported for the connection. After this call, getWarnings() returns null until a new warning is reported for the connection.

Specified by:
clearWarnings in interface Connection
Throws:
SQLException - If an error occurs.

close

public void close()
           throws SQLException
Closes the handle to the connection. This does not close the underlying physical connection to the database. The handle is set to an unuseable state.

Specified by:
close in interface Connection
Throws:
SQLException - If an error occurs.

commit

public void commit()
            throws SQLException
Commits all changes made since the previous commit or rollback and releases any database locks currently held by the connection. This has no effect when the connection is in auto-commit mode.

Specified by:
commit in interface Connection
Throws:
SQLException - If the connection is not open or an error occurs.

createStatement

public Statement createStatement()
                          throws SQLException
Creates a Statement object for executing SQL statements without parameters. If the same SQL statement is executed many times, it is more efficient to use prepareStatement().

Result sets created using the statement will be type ResultSet.TYPE_FORWARD_ONLY and concurrency ResultSet.CONCUR_READ_ONLY.

Specified by:
createStatement in interface Connection
Returns:
The statement object.
Throws:
SQLException - If the connection is not open, the maximum number of statements for this connection has been reached, or an error occured.

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency)
                          throws SQLException
Creates a Statement object for executing SQL statements without parameters. If the same SQL statement is executed many times, it is more efficient to use prepareStatement().

Specified by:
createStatement in interface Connection
Parameters:
resultSetType - The result set type. Valid values are:
  • ResultSet.TYPE_FORWARD_ONLY
  • ResultSet.TYPE_SCROLL_INSENSITIVE
  • ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - The result set concurrency. Valid values are:
  • ResultSet.CONCUR_READ_ONLY
  • ResultSet.CONCUR_UPDATABLE
Returns:
The statement object.
Throws:
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.

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency,
                                 int resultSetHoldability)
                          throws SQLException
Creates a Statement object for executing SQL statements without parameters. If the same SQL statement is executed many times, it is more efficient to use prepareStatement().

Full functionality of this method requires support in OS/400 V5R2 or i5/0S. If connecting to OS/400 V5R1 or earlier, the value for resultSetHoldability will be ignored.

Specified by:
createStatement in interface Connection
Parameters:
resultSetType - The result set type. Valid values are:
  • ResultSet.TYPE_FORWARD_ONLY
  • ResultSet.TYPE_SCROLL_INSENSITIVE
  • ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - The result set concurrency. Valid values are:
  • ResultSet.CONCUR_READ_ONLY
  • ResultSet.CONCUR_UPDATABLE
resultSetHoldability - The result set holdability. Valid values are:
  • ResultSet.HOLD_CURSORS_OVER_COMMIT
  • ResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
The statement object.
Throws:
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.
Since:
Modification 5

finalize

protected void finalize()
                 throws Throwable
Closes the connection if not explicitly closed by the caller.

Throws:
Throwable - If an error occurs.

getAutoCommit

public boolean getAutoCommit()
                      throws SQLException
Returns the auto-commit state.

Specified by:
getAutoCommit in interface Connection
Returns:
true if the connection is in auto-commit mode; false otherwise.
Throws:
SQLException - If the connection is not open.

getCatalog

public String getCatalog()
                  throws SQLException
Returns the catalog name.

Specified by:
getCatalog in interface Connection
Returns:
The catalog name.
Throws:
SQLException - If the connection is not open.

getHoldability

public int getHoldability()
                   throws SQLException
Returns the holdability of ResultSets created from this connection.

Specified by:
getHoldability in interface Connection
Returns:
The cursor holdability. Valid values are ResultSet.HOLD_CURSORS_OVER_COMMIT and ResultSet.CLOSE_CURSORS_AT_COMMIT. The holdability is derived in this order of precedence:
  • 1. The holdability specified using the method setHoldability(int) if this method was called.
  • 2. The value of the cursor hold driver property.
Full functionality of #1 requires support in OS/400 V5R2 or i5/OS. If connecting to OS/400 V5R1 or earlier, the value specified on this method will be ignored and the default holdability will be the value of #2.
Throws:
SQLException - If the connection is not open.
Since:
Modification 5

getMetaData

public DatabaseMetaData getMetaData()
                             throws SQLException
Returns the DatabaseMetaData object that describes the connection's tables, supported SQL grammar, stored procedures, capabilities and more.

Specified by:
getMetaData in interface Connection
Returns:
The metadata object.
Throws:
SQLException - If an error occurs.

getServerJobIdentifier

public String getServerJobIdentifier()
                              throws SQLException
Returns the job identifier of the host server job corresponding to this connection. Every JDBC connection is associated with a host server job on the system. The format is:

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();
  

Returns:
The server job identifier, or null if not known.
Throws:
SQLException - If the connection is not open.

getTransactionIsolation

public int getTransactionIsolation()
                            throws SQLException
Returns the transaction isolation level.

Specified by:
getTransactionIsolation in interface Connection
Returns:
The transaction isolation level. Possible values are:
  • TRANSACTION_NONE
  • TRANSACTION_READ_UNCOMMITTED
  • TRANSACTION_READ_COMMITTED
  • TRANSACTION_REPEATABLE_READ
Throws:
SQLException - If the connection is not open.

getTypeMap

public Map getTypeMap()
               throws SQLException
Returns the type map.

This driver does not support the type map.

Specified by:
getTypeMap in interface Connection
Returns:
The type map.
Throws:
SQLException - This exception is always thrown.

getWarnings

public SQLWarning getWarnings()
                       throws SQLException
Returns the first warning reported for the connection. Subsequent warnings may be chained to this warning.

Specified by:
getWarnings in interface Connection
Returns:
The first warning or null if no warnings have been reported.
Throws:
SQLException - If an error occurs.

isClosed

public boolean isClosed()
                 throws SQLException
Indicates if the connection is closed.

Specified by:
isClosed in interface Connection
Returns:
true if the connection is closed; false otherwise.
Throws:
SQLException - If an error occurs.

isReadOnly

public boolean isReadOnly()
                   throws SQLException
Indicates if the connection is in read-only mode.

Specified by:
isReadOnly in interface Connection
Returns:
true if the connection is in read-only mode; false otherwise.
Throws:
SQLException - If the connection is not open.

nativeSQL

public String nativeSQL(String sql)
                 throws SQLException
Returns the native form of an SQL statement without executing it. The JDBC driver converts all SQL statements from the JDBC SQL grammar into the native DB2 for i5/OS SQL grammar prior to executing them.

Specified by:
nativeSQL in interface Connection
Parameters:
sql - The SQL statement in terms of the JDBC SQL grammar.
Returns:
The translated SQL statement in the native DB2 for i5/OS SQL grammar.
Throws:
SQLException - If the SQL statement has a syntax error.

prepareCall

public CallableStatement prepareCall(String sql)
                              throws SQLException
Precompiles an SQL stored procedure call with optional input and output parameters and stores it in a CallableStatement object. This object can be used to efficiently call the SQL stored procedure multiple times.

Result sets created using the statement will be type ResultSet.TYPE_FORWARD_ONLY and concurrency ResultSet.CONCUR_READ_ONLY.

Specified by:
prepareCall in interface Connection
Parameters:
sql - The SQL stored procedure call.
Returns:
The callable statement object.
Throws:
SQLException - If the connection is not open, the maximum number of statements for this connection has been reached, or an error occurs.

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency)
                              throws SQLException
Precompiles an SQL stored procedure call with optional input and output parameters and stores it in a CallableStatement object. This object can be used to efficiently call the SQL stored procedure multiple times.

Specified by:
prepareCall in interface Connection
Parameters:
sql - The SQL statement.
resultSetType - The result set type. Valid values are:
  • ResultSet.TYPE_FORWARD_ONLY
  • ResultSet.TYPE_SCROLL_INSENSITIVE
  • ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - The result set concurrency. Valid values are:
  • ResultSet.CONCUR_READ_ONLY
  • ResultSet.CONCUR_UPDATABLE
Returns:
The prepared statement object.
Throws:
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.

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability)
                              throws SQLException
Precompiles an SQL stored procedure call with optional input and output parameters and stores it in a CallableStatement object. This object can be used to efficiently call the SQL stored procedure multiple times.

Full functionality of this method requires support in OS/400 V5R2 or i5/OS. If connecting to OS/400 V5R1 or earlier, the value for resultSetHoldability will be ignored.

Specified by:
prepareCall in interface Connection
Parameters:
sql - The SQL statement.
resultSetType - The result set type. Valid values are:
  • ResultSet.TYPE_FORWARD_ONLY
  • ResultSet.TYPE_SCROLL_INSENSITIVE
  • ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - The result set concurrency. Valid values are:
  • ResultSet.CONCUR_READ_ONLY
  • ResultSet.CONCUR_UPDATABLE
resultSetHoldability - The result set holdability. Valid values are:
  • ResultSet.HOLD_CURSORS_OVER_COMMIT
  • ResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
The prepared statement object.
Throws:
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.
Since:
Modification 5

prepareStatement

public PreparedStatement prepareStatement(String sql)
                                   throws SQLException
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. This object can be used to efficiently execute this SQL statement multiple times.

Result sets created using the statement will be type ResultSet.TYPE_FORWARD_ONLY and concurrency ResultSet.CONCUR_READ_ONLY.

Specified by:
prepareStatement in interface Connection
Parameters:
sql - The SQL statement.
Returns:
The prepared statement object.
Throws:
SQLException - If the connection is not open, the maximum number of statements for this connection has been reached, or an error occurs.

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int autoGeneratedKeys)
                                   throws SQLException
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. This object can be used to efficiently execute this SQL statement multiple times.

This method requires OS/400 V5R2 or i5/OS. If connecting to OS/400 V5R1 or earlier, an exception will be thrown.

Result sets created using the statement will be type ResultSet.TYPE_FORWARD_ONLY and concurrency ResultSet.CONCUR_READ_ONLY.

Specified by:
prepareStatement in interface Connection
Parameters:
sql - The SQL statement.
autoGeneratedKeys - Whether to return auto generated keys. Valid values are:
  • Statement.RETURN_GENERATED_KEYS
  • Statement.NO_GENERATED_KEYS
Returns:
The prepared statement object.
Throws:
SQLException - If the connection is not open, the maximum number of statements for this connection has been reached, if connecting to OS/400 V5R1 or earlier, an error occurs.
Since:
Modification 5

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int[] columnIndexes)
                                   throws SQLException
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. This object can be used to efficiently execute this SQL statement multiple times.

This method is not supported. An SQLException is always thrown.

Specified by:
prepareStatement in interface Connection
Parameters:
sql - The SQL statement.
columnIndexes - An array of column indexes indicating the columns that should be returned from the inserted row or rows.
Returns:
An SQLException is always thrown. This method is not supported.
Throws:
SQLException - - Always thrown because the Toolbox JDBC driver does does not support this method.
Since:
Modification 5

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency)
                                   throws SQLException
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. This object can be used to efficiently execute this SQL statement multiple times.

Specified by:
prepareStatement in interface Connection
Parameters:
sql - The SQL statement.
resultSetType - The result set type. Valid values are:
  • ResultSet.TYPE_FORWARD_ONLY
  • ResultSet.TYPE_SCROLL_INSENSITIVE
  • ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - The result set concurrency. Valid values are:
  • ResultSet.CONCUR_READ_ONLY
  • ResultSet.CONCUR_UPDATABLE
Returns:
The prepared statement object.
Throws:
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.

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws SQLException
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. This object can be used to efficiently execute this SQL statement multiple times.

Specified by:
prepareStatement in interface Connection
Parameters:
sql - The SQL statement.
resultSetType - The result set type. Valid values are:
  • ResultSet.TYPE_FORWARD_ONLY
  • ResultSet.TYPE_SCROLL_INSENSITIVE
  • ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency - The result set concurrency. Valid values are:
  • ResultSet.CONCUR_READ_ONLY
  • ResultSet.CONCUR_UPDATABLE
resultSetHoldability - The result set holdability. Valid values are:
  • ResultSet.HOLD_CURSORS_OVER_COMMIT
  • ResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
The prepared statement object.
Throws:
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.

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          String[] columnNames)
                                   throws SQLException
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object. This object can be used to efficiently execute this SQL statement multiple times.

This method is not supported. An SQLException is always thrown.

Specified by:
prepareStatement in interface Connection
Parameters:
sql - The SQL statement.
columnNames - An array of column names indicating the columns that should be returned from the inserted row or rows.
Returns:
An SQLException is always thrown. This method is not supported.
Throws:
SQLException - - Always thrown because the Toolbox JDBC driver does does not support this method.
Since:
Modification 5

releaseSavepoint

public void releaseSavepoint(Savepoint savepoint)
                      throws SQLException
Removes the given Savepoint object from the current transaction. Any reference to the savepoint after it has been removed will cause an SQLException to be thrown.

Specified by:
releaseSavepoint in interface Connection
Parameters:
savepoint - the savepoint to be removed.
Throws:
SQLException - if a database access error occurs or the given Savepoint is not a valid savepoint in the current transaction.
Since:
Modification 5

rollback

public void rollback()
              throws SQLException
Drops all changes made since the previous commit or rollback and releases any database locks currently held by the connection. This has no effect when the connection is in auto-commit mode.

Specified by:
rollback in interface Connection
Throws:
SQLException - If the connection is not open or an error occurs.

rollback

public void rollback(Savepoint savepoint)
              throws SQLException
Undoes all changes made after the specified Savepoint was set.

Specified by:
rollback in interface Connection
Parameters:
savepoint - the savepoint to be rolled back to.
Throws:
SQLException - if a database access error occurs, the Savepoint is no longer valid, or this Connection is currently in auto-commit mode.
Since:
Modification 5

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws SQLException
Sets the auto-commit mode. If the connection is in auto-commit mode, then all of its SQL statements are executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by either a commit or rollback.

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.

Specified by:
setAutoCommit in interface Connection
Parameters:
autoCommit - true to turn on auto-commit mode, false to turn it off.
Throws:
SQLException - If the connection is not open or an error occurs.

setDB2eWLMCorrelator

public void setDB2eWLMCorrelator(byte[] bytes)
                          throws SQLException
Sets the eWLM Correlator. It is assumed a valid correlator value is used. If the value is null, all ARM/eWLM implementation will be turned off. eWLM correlators require i5/OS V5R3 or later systems. This request is ignored when running to OS/400 V5R2 or earlier systems.

Parameters:
bytes - The eWLM correlator value
Throws:
SQLException

setCatalog

public void setCatalog(String catalog)
                throws SQLException
This method is not supported.

Specified by:
setCatalog in interface Connection
Throws:
SQLException - If the connection is not open.

setHoldability

public void setHoldability(int holdability)
                    throws SQLException
Sets the holdability of ResultSets created from this connection.

Full functionality of this method requires OS/400 V5R2 or i5/OS. If connecting to OS/400 V5R1 or earlier, all cursors for the connection will be changed to the value of the variable holdability.

Specified by:
setHoldability in interface Connection
Parameters:
holdability - The cursor holdability. Valid values are ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT.
Throws:
SQLException - If the connection is not open or the value passed in is not valid.
Since:
Modification 5

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws SQLException
Sets the read-only mode. This will provide read-only access to the database. Read-only mode can be useful by enabling certain database optimizations. If the caller specified "read only" or "read call" for the "access" property, then the read-only mode cannot be set to false. The read-only mode cannot be changed while in the middle of a transaction.

Specified by:
setReadOnly in interface Connection
Parameters:
readOnly - true to set the connection to read-only mode; false to set the connection to read-write mode.
Throws:
SQLException - If the connection is not open, a transaction is active, or the "access" property is set to "read only".

setSavepoint

public Savepoint setSavepoint()
                       throws SQLException
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.

Specified by:
setSavepoint in interface Connection
Returns:
The new Savepoint object.
Throws:
SQLException - if a database access error occurs or this Connection object is currently in auto-commit mode.
Since:
Modification 5

setSavepoint

public Savepoint setSavepoint(String name)
                       throws SQLException
Creates a named savepoint in the current transaction and returns the new Savepoint object that represents it.

Specified by:
setSavepoint in interface Connection
Parameters:
name - A String containing the name of the savepoint
Returns:
The new Savepoint object.
Throws:
SQLException - if a database access error occurs or this Connection object is currently in auto-commit mode.
Since:
Modification 5

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws SQLException
Sets the transaction isolation level. The transaction isolation level cannot be changed while in the middle of a transaction.

JDBC and DB2 for i5/OS use different terminology for transaction isolation levels. The following table provides a terminology mapping:

DB2 for i5/OS isolation levelJDBC transaction isolation level
*CHG TRANSACTION_READ_UNCOMMITTED
*CS TRANSACTION_READ_COMMITTED
*ALL TRANSACTION_READ_REPEATABLE_READ
*RR TRANSACTION_SERIALIZABLE

Specified by:
setTransactionIsolation in interface Connection
Parameters:
level - The transaction isolation level. Possible values are:
  • TRANSACTION_READ_UNCOMMITTED
  • TRANSACTION_READ_COMMITTED
  • TRANSACTION_REPEATABLE_READ
  • TRANSACTION_SERIALIZABLE
Throws:
SQLException - If the connection is not open, the input level is not valid or unsupported, or a transaction is active.

setTypeMap

public void setTypeMap(Map typeMap)
                throws SQLException
Sets the type map to be used for distinct and structured types.

Note: Distinct types are supported by DB2 for i5/OS, 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 for i5/OS. Consequently, this driver does not support the type map.

Specified by:
setTypeMap in interface Connection
Parameters:
typeMap - The type map.
Throws:
SQLException - This exception is always thrown.

toString

public String toString()
Returns the connection's catalog name. This is the name of the i5/OS system.

Returns:
The catalog name.

setDBHostServerTrace

public void setDBHostServerTrace(boolean trace)
                          throws SQLException
Starts or stops the Database Host Server trace for this connection. Note: This method is only supported when running to i5/OS V5R3 or later and is ignored if you specified to turn on database host server tracing using the 'server trace' connection property.

Parameters:
trace - true to start database host server tracing, false to end it.
Throws:
SQLException

setClientInfo

public void setClientInfo(String name,
                          String value)
                   throws SQLException
Sets the value of the client info property specified by name to the value specified by value.

Applications may use the DatabaseMetaData.getClientInfoProperties method to determine the client info properties supported by the driver and the maximum length that may be specified for each property.

The driver stores the value specified in a suitable location in the database. For example in a special register, session parameter, or system table column. For efficiency the driver may defer setting the value in the database until the next time a statement is executed or prepared. Other than storing the client information in the appropriate place in the database, these methods shall not alter the behavior of the connection in anyway. The values supplied to these methods are used for accounting, diagnostics and debugging purposes only.

The driver shall generate a warning if the client info name specified is not recognized by the driver.

If the value specified to this method is greater than the maximum length for the property the driver may either truncate the value and generate a warning or generate a SQLException. If the driver generates a SQLException, the value specified was not set on the connection.

The following client info properties are supported in Toobox for Java.

Parameters:
name - The name of the client info property to set
value - The value to set the client info property to. If the value is null, the current value of the specified property is cleared.

Throws:
SQLException - if the database server returns an error while setting the client info value on the database server.


setClientInfo

public void setClientInfo(Properties properties)
                   throws SQLException
Sets the value of the connection's client info properties. The Properties object contains the names and values of the client info properties to be set. The set of client info properties contained in the properties list replaces the current set of client info properties on the connection. If a property that is currently set on the connection is not present in the properties list, that property is cleared. Specifying an empty properties list will clear all of the properties on the connection. See setClientInfo (String, String) for more information.

If an error occurs in setting any of the client info properties, a ClientInfoException is thrown. The ClientInfoException contains information indicating which client info properties were not set. The state of the client information is unknown because some databases do not allow multiple client info properties to be set atomically. For those databases, one or more properties may have been set before the error occurred.

The following client info properties are supported in Toobox for Java.

Parameters:
properties - the list of client info properties to set

Throws:
SQLException - if the database server returns an error while setting the clientInfo values on the database server

see java.sql.Connection#setClientInfo(String, String) setClientInfo(String, String)


getClientInfo

public String getClientInfo(String name)
                     throws SQLException
Returns the value of the client info property specified by name. This method may return null if the specified client info property has not been set and does not have a default value. This method will also return null if the specified client info property name is not supported by the driver.

Applications may use the DatabaseMetaData.getClientInfoProperties method to determine the client info properties supported by the driver.

The following client info properties are supported in Toobox for Java.

Parameters:
name - The name of the client info property to retrieve

Returns:
The value of the client info property specified

Throws:
SQLException - if the database server returns an error when fetching the client info value from the database.

see java.sql.DatabaseMetaData#getClientInfoProperties


getClientInfo

public Properties getClientInfo()
                         throws SQLException
Returns a list containing the name and current value of each client info property supported by the driver. The value of a client info property may be null if the property has not been set and does not have a default value.

The following client info properties are supported in Toobox for Java.

Returns:
A Properties object that contains the name and current value of each of the client info properties supported by the driver.

Throws:
SQLException - if the database server returns an error when fetching the client info values from the database