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() or AS400JDBCDriver.connect() to create new AS400JDBCConnection objects.

See Also:
AS400JDBCStatement, AS400JDBCResultSet, AS400JDBCDatabaseMetaData

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 an AS400JDBCStatement object for executing SQL statements without parameters.
 o finalize()
Closes the connection if not explicitly closed by the caller.
 o getAutoCommit()
Returns the current auto-commit state.
 o getCatalog()
Returns the connection's catalog name.
 o getMetaData()
Returns the AS400JDBCDatabaseMetaData object that describes the connection's tables, supported SQL grammar, stored procedures, capabilities and more.
 o getTransactionIsolation()
Returns the current transaction isolation level.
 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 a SQL statement without executing it.
 o prepareCall(String)
Precompiles a SQL stored procedure call with optional input and output parameters and stores it in an AS400JDBCCallableStatement object.
 o prepareStatement(String)
Precompiles a SQL statement with optional input parameters and stores it in an AS400JDBCPreparedStatement 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 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.
See Also:
isClosed
 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.
See Also:
rollback
 o createStatement
 public Statement createStatement() throws SQLException
Creates an AS400JDBCStatement object for executing SQL statements without parameters. If the same SQL statement is executed many times, it is more efficient to use prepareStatement().

Returns:
The statement object.
Throws: SQLException
If the connection is not open 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 current auto-commit state.

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

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

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

Returns:
Either TRANSACTION_NONE, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, or TRANSACTION_REPEATABLE_READ.
Throws: SQLException
If the connection is not open.
See Also:
setTransactionIsolation
 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.
See Also:
clearWarnings
 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.
See Also:
close
 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.
See Also:
setReadOnly
 o nativeSQL
 public String nativeSQL(String sql) throws SQLException
Returns the native form of a 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 a SQL stored procedure call with optional input and output parameters and stores it in an AS400JDBCCallableStatement object. This object can be used to efficiently call the SQL stored procedure multiple times.

Parameters:
sql - The SQL stored procedure call.
Returns:
The callable statement object.
Throws: SQLException
If the connection is not open or an error occurs.
 o prepareStatement
 public PreparedStatement prepareStatement(String sql) throws SQLException
Precompiles a SQL statement with optional input parameters and stores it in an AS400JDBCPreparedStatement object. This object can be used to efficiently execute this SQL statement multiple times.

Parameters:
sql - The SQL statement.
Returns:
The prepared statement object.
Throws: SQLException
If the connection is not open 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.
See Also:
commit
 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.
See Also:
getAutoCommit
 o setCatalog
 public void setCatalog(String catalog) throws SQLException
This method is not supported.

Throws: SQLException
If the connection is not open.
See Also:
getCatalog
 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" 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".
See Also:
isReadOnly
 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 - Either TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ, or TRANSACTION_SERIALIZABLE.
Throws: SQLException
If the connection is not open, the input level is not valid or unsupported, or a transaction is active.
See Also:
getTransactionIsolation
 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