com.ibm.as400.micro
Class JdbcMeConnection

java.lang.Object
  |
  +--com.ibm.as400.micro.JdbcMeConnection
All Implemented Interfaces:
java.sql.Connection

public class JdbcMeConnection
extends java.lang.Object
implements java.sql.Connection

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

There are many optional properties that can be specified when the connection is created. Properties can be specified either as part of the URL or in a java.util.Properties object. See JDBC properties for a complete list of properties supported by the JdbcMeDriver.

Note: Since Java 2 Micro-Edition does not include java.sql, JdbcMeConnection implements the java.sql package that is also part of this driver.


Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Method Summary
 void close()
          Releases the connection's resources immediately instead of waiting for them to be automatically released.
 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)
          Create a Statement object that can be used to directly execute SQL.
 boolean getAutoCommit()
          Returns the auto-commit state.
 int getTransactionIsolation()
          Returns the transaction isolation level.
 boolean isClosed()
          Indicates if the connection is closed.
 void rollback()
          Drops all changes made since the previous commit or rollback and releases any database locks currently held by the connection.
 void setAutoCommit(boolean autoCommit)
          Sets the auto-commit mode.
 void setTransactionIsolation(int isolation)
          Sets the transaction isolation level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.sql.Connection
clearWarnings, getCatalog, getMetaData, getTypeMap, getWarnings, isReadOnly, nativeSQL, prepareCall, prepareCall, prepareStatement, prepareStatement, setCatalog, setReadOnly, setTypeMap
 

Method Detail

close

public void close()
           throws JdbcMeException
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.
Specified by:
close in interface java.sql.Connection
Throws:
JdbcMeException - If an error occurs.

createStatement

public java.sql.Statement createStatement()
                                   throws JdbcMeException
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 java.sql.Connection
Returns:
The statement object.
Throws:
JdbcMeException - If the connection is not open, the maximum number of statements for this connection has been reached, or an error occurs.

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws JdbcMeException
Create a Statement object that can be used to directly execute SQL.
Specified by:
createStatement in interface java.sql.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:
JdbcMeException - 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.

isClosed

public boolean isClosed()
                 throws JdbcMeException
Indicates if the connection is closed.
Specified by:
isClosed in interface java.sql.Connection
Throws:
JdbcMeException - If an error occurs.

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws JdbcMeException
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 java.sql.Connection
Parameters:
autoCommit - true to turn on auto-commit mode, false to turn it off.
Throws:
JdbcMeException - If the connection is not open or an error occurs.

getAutoCommit

public boolean getAutoCommit()
                      throws JdbcMeException
Returns the auto-commit state.
Specified by:
getAutoCommit in interface java.sql.Connection
Returns:
true if the connection is in auto-commit mode; false otherwise.
Throws:
JdbcMeException - If an error occurs.

commit

public void commit()
            throws JdbcMeException
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. exception JdbcMeException If the connection is not open or an error occurs.
Specified by:
commit in interface java.sql.Connection

rollback

public void rollback()
              throws JdbcMeException
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 java.sql.Connection
Throws:
JdbcMeException - If the connection is not open or an error occurs.

getTransactionIsolation

public int getTransactionIsolation()
                            throws JdbcMeException
Returns the transaction isolation level.
Specified by:
getTransactionIsolation in interface java.sql.Connection
Returns:
The transaction isolation level. Possible values are:
  • TRANSACTION_NONE
  • TRANSACTION_READ_UNCOMMITTED
  • TRANSACTION_READ_COMMITTED
  • TRANSACTION_REPEATABLE_READ
Throws:
JdbcMeException - If an error occurs.

setTransactionIsolation

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

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

AS/400 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 java.sql.Connection
Parameters:
level - The transaction isolation level. Possible values are:
  • TRANSACTION_READ_UNCOMMITTED
  • TRANSACTION_READ_COMMITTED
  • TRANSACTION_REPEATABLE_READ
  • TRANSACTION_SERIALIZABLE
Throws:
JdbcMeException - If the connection is not open, the input level is not valid or unsupported, or a transaction is active.