com.ibm.as400.micro
Class JdbcMeConnection

java.lang.Object
  extended by com.ibm.as400.micro.JdbcMeConnection
All Implemented Interfaces:
Connection

public class JdbcMeConnection
extends Object
implements Connection

The JdbcMeConnection class provides a JDBC connection to a specific DB2 for IBM i 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.


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()
           
 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.
 Statement createStatement()
          Creates a Statement object for executing SQL statements without parameters.
 Statement createStatement(int resultSetType, int resultSetConcurrency)
          Create a Statement object that can be used to directly execute SQL.
 Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
           
 boolean getAutoCommit()
          Returns the auto-commit state.
 String getCatalog()
           
 int getHoldability()
           
 DatabaseMetaData getMetaData()
           
 int getTransactionIsolation()
          Returns the transaction isolation level.
 Map getTypeMap()
           
 SQLWarning getWarnings()
           
 boolean isClosed()
          Indicates if the connection is closed.
 boolean isReadOnly()
           
 String nativeSQL(String sql)
           
 CallableStatement prepareCall(String sql)
           
 CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
           
 CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
           
 PreparedStatement prepareStatement(String sql)
           
 PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
           
 PreparedStatement prepareStatement(String sql, int[] columnIndexes)
           
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
           
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
           
 PreparedStatement prepareStatement(String sql, String[] columnNames)
           
 void releaseSavepoint(Savepoint savepoint)
           
 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)
           
 void setAutoCommit(boolean autoCommit)
          Sets the auto-commit mode.
 void setCatalog(String catalog)
           
 void setHoldability(int holdability)
           
 void setReadOnly(boolean readOnly)
           
 Savepoint setSavepoint()
           
 Savepoint setSavepoint(String name)
           
 void setTransactionIsolation(int isolation)
          Sets the transaction isolation level.
 void setTypeMap(Map map)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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

createStatement

public 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 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 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 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 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 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 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 Connection
Throws:
JdbcMeException

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 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 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 Connection
Parameters:
isolation - 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.

clearWarnings

public void clearWarnings()
                   throws SQLException
Specified by:
clearWarnings in interface Connection
Throws:
SQLException

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency,
                                 int resultSetHoldability)
                          throws SQLException
Specified by:
createStatement in interface Connection
Throws:
SQLException

getCatalog

public String getCatalog()
                  throws SQLException
Specified by:
getCatalog in interface Connection
Throws:
SQLException

getHoldability

public int getHoldability()
                   throws SQLException
Specified by:
getHoldability in interface Connection
Throws:
SQLException

getMetaData

public DatabaseMetaData getMetaData()
                             throws SQLException
Specified by:
getMetaData in interface Connection
Throws:
SQLException

getWarnings

public SQLWarning getWarnings()
                       throws SQLException
Specified by:
getWarnings in interface Connection
Throws:
SQLException

isReadOnly

public boolean isReadOnly()
                   throws SQLException
Specified by:
isReadOnly in interface Connection
Throws:
SQLException

nativeSQL

public String nativeSQL(String sql)
                 throws SQLException
Specified by:
nativeSQL in interface Connection
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql)
                              throws SQLException
Specified by:
prepareCall in interface Connection
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency)
                              throws SQLException
Specified by:
prepareCall in interface Connection
Throws:
SQLException

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability)
                              throws SQLException
Specified by:
prepareCall in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql)
                                   throws SQLException
Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int autoGeneratedKeys)
                                   throws SQLException
Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int[] columnIndexes)
                                   throws SQLException
Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          String[] columnNames)
                                   throws SQLException
Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency)
                                   throws SQLException
Specified by:
prepareStatement in interface Connection
Throws:
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws SQLException
Specified by:
prepareStatement in interface Connection
Throws:
SQLException

releaseSavepoint

public void releaseSavepoint(Savepoint savepoint)
                      throws SQLException
Specified by:
releaseSavepoint in interface Connection
Throws:
SQLException

rollback

public void rollback(Savepoint savepoint)
              throws SQLException
Specified by:
rollback in interface Connection
Throws:
SQLException

setCatalog

public void setCatalog(String catalog)
                throws SQLException
Specified by:
setCatalog in interface Connection
Throws:
SQLException

setHoldability

public void setHoldability(int holdability)
                    throws SQLException
Specified by:
setHoldability in interface Connection
Throws:
SQLException

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws SQLException
Specified by:
setReadOnly in interface Connection
Throws:
SQLException

setSavepoint

public Savepoint setSavepoint()
                       throws SQLException
Specified by:
setSavepoint in interface Connection
Throws:
SQLException

setSavepoint

public Savepoint setSavepoint(String name)
                       throws SQLException
Specified by:
setSavepoint in interface Connection
Throws:
SQLException

getTypeMap

public Map getTypeMap()
               throws SQLException
Specified by:
getTypeMap in interface Connection
Throws:
SQLException

setTypeMap

public void setTypeMap(Map map)
                throws SQLException
Specified by:
setTypeMap in interface Connection
Throws:
SQLException