All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.access.AS400JDBCConnection

java.lang.Object
   |
   +----com.ibm.as400.access.AS400JDBCConnection

public class AS400JDBCConnection
extends Object
implements Connection

The AS400JDBCConnection class provides a JDBC connection to a specific DB2 for OS/400 database. Use DriverManager.getConnection() to create new AS400JDBCConnection objects.

Note that a connection may contain at most 256 open statements.


Method Index

 o clearWarnings()
Clears all warnings that have been reported for the connection.
 o close()
Releases the connection's resources immediately instead of waiting for them to be automatically released.
 o commit()
Commits all changes made since the previous commit or rollback and releases any database locks currently held by the connection.
 o createStatement()
Creates a Statement object for executing SQL statements without parameters.
 o createStatement(int, int)
Creates a Statement object for executing SQL statements without parameters.
 o finalize()
Closes the connection if not explicitly closed by the caller.
 o getAutoCommit()
Returns the auto-commit state.
 o getCatalog()
Returns the catalog name.
 o getMetaData()
Returns the DatabaseMetaData object that describes the connection's tables, supported SQL grammar, stored procedures, capabilities and more.
 o getTransactionIsolation()
Returns the transaction isolation level.
 o getTypeMap()
Returns the type map.
 o getWarnings()
Returns the first warning reported for the connection.
 o isClosed()
Indicates if the connection is closed.
 o isReadOnly()
Indicates if the connection is in read-only mode.
 o nativeSQL(String)
Returns the native form of an SQL statement without executing it.
 o prepareCall(String)
Precompiles an SQL stored procedure call with optional input and output parameters and stores it in a CallableStatement object.
 o prepareCall(String, int, int)
Precompiles an SQL stored procedure call with optional input and output parameters and stores it in a CallableStatement object.
 o prepareStatement(String)
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object.
 o prepareStatement(String, int, int)
Precompiles an SQL statement with optional input parameters and stores it in a PreparedStatement object.
 o rollback()
Drops all changes made since the previous commit or rollback and releases any database locks currently held by the connection.
 o setAutoCommit(boolean)
Sets the auto-commit mode.
 o setCatalog(String)
This method is not supported.
 o setReadOnly(boolean)
Sets the read-only mode.
 o setTransactionIsolation(int)
Sets the transaction isolation level.
 o setTypeMap(Map)
Sets the type map to be used for distinct and structured types.
 o toString()
Returns the connection's catalog name.

Methods

 o 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.

Throws: SQLException
If an error occurs.
 o close
 public void close() throws SQLException
Releases the connection's resources immediately instead of waiting for them to be automatically released. This rolls back any active transactions, closes all statements that are running in the context of the connection, and disconnects from the server.

Throws: SQLException
If an error occurs.
 o 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.

Throws: SQLException
If the connection is not open or an error occurs.
 o 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.

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 occurs.
 o 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().

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 occurs.
 o finalize
 protected void finalize() throws Throwable
Closes the connection if not explicitly closed by the caller.

Throws: Throwable
If an error occurs.
Overrides:
finalize in class Object
 o getAutoCommit
 public boolean getAutoCommit() throws SQLException
Returns the auto-commit state.

Returns:
true if the connection is in auto-commit mode; false otherwise.
Throws: SQLException
If the connection is not open.
 o getCatalog
 public String getCatalog() throws SQLException
Returns the catalog name.

Returns:
The catalog name.
Throws: SQLException
If the connection is not open.
 o getMetaData
 public DatabaseMetaData getMetaData() throws SQLException
Returns the DatabaseMetaData object that describes the connection's tables, supported SQL grammar, stored procedures, capabilities and more.

Returns:
The metadata object.
Throws: SQLException
If an error occurs.
 o getTransactionIsolation
 public int getTransactionIsolation() throws SQLException
Returns the transaction isolation level.

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.
 o getTypeMap
 public Map getTypeMap() throws SQLException
Returns the type map.

This driver does not support the type map.

Returns:
The type map.
Throws: SQLException
This exception is always thrown.
 o getWarnings
 public SQLWarning getWarnings() throws SQLException
Returns the first warning reported for the connection. Subsequent warnings may be chained to this warning.

Returns:
The first warning or null if no warnings have been reported.
Throws: SQLException
If an error occurs.
 o isClosed
 public boolean isClosed() throws SQLException
Indicates if the connection is closed.

Returns:
true if the connection is closed; false otherwise.
Throws: SQLException
If an error occurs.
 o isReadOnly
 public boolean isReadOnly() throws SQLException
Indicates if the connection is in read-only mode.

Returns:
true if the connection is in read-only mode; false otherwise.
Throws: SQLException
If the connection is not open.
 o 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 OS/400 SQL grammar prior to executing them.

Parameters:
sql - The SQL statement in terms of the JDBC SQL grammar.
Returns:
The translated SQL statement in the native DB2 for OS/400 SQL grammar.
Throws: SQLException
If the SQL statement has a syntax error.
 o 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.

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.
 o 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.

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.
 o 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.

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.
 o 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.

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.
 o 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.

Throws: SQLException
If the connection is not open or an error occurs.
 o 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.

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.
 o setCatalog
 public void setCatalog(String catalog) throws SQLException
This method is not supported.

Throws: SQLException
If the connection is not open.
 o 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.

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".
 o 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.

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.
 o 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 OS/400, but are not externalized by the AS/400 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 OS/400. Consequently, this driver does not support the type map.

Parameters:
typeMap - The type map.
Throws: SQLException
This exception is always thrown.
 o toString
 public String toString()
Returns the connection's catalog name. This is the name of the server.

Returns:
The catalog name.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index