com.ibm.as400.micro
Class JdbcMeStatement

java.lang.Object
  extended by com.ibm.as400.micro.JdbcMeStatement
All Implemented Interfaces:
Statement

public class JdbcMeStatement
extends Object
implements Statement

The AS400JDBCStatement class provides a mechanism for executing static SQL statements. Use Connection.createStatement() to create new Statement objects.

Only one result set per statement can be open at any point in time. Therefore, if an application needs to read from multiple result sets, then each must be generated by a different statement.

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


Field Summary
 
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
 
Method Summary
 void addBatch(String sql)
           
 void cancel()
           
 void clearBatch()
           
 void clearWarnings()
           
 void close()
          Releases the statement's resources.
 boolean execute(String sql)
          Runs an SQL statement that may return multiple result sets.
 boolean execute(String sql, int autoGeneratedKeys)
           
 boolean execute(String sql, int[] columnIndexes)
           
 boolean execute(String sql, String[] columnNames)
           
 int[] executeBatch()
           
 ResultSet executeQuery(String sql)
          Runs an SQL statement that returns a single result set.
 boolean executeToOfflineData(String sql, String dbName, int dbCreator, int dbType)
          Create or overwrite an offline device specific database containing the results of the query specified.
 int executeUpdate(String sql)
          Runs an SQL INSERT, UPDATE, or DELETE statement, or any SQL statement that does not return a result set.
 int executeUpdate(String sql, int autoGeneratedKeys)
           
 int executeUpdate(String sql, int[] columnIndexes)
           
 int executeUpdate(String sql, String[] columnNames)
           
 Connection getConnection()
          Returns the connection for this statement.
 int getFetchDirection()
           
 int getFetchSize()
           
 ResultSet getGeneratedKeys()
           
 int getMaxFieldSize()
           
 int getMaxRows()
           
 boolean getMoreResults()
           
 boolean getMoreResults(int current)
           
 int getQueryTimeout()
           
 ResultSet getResultSet()
          Returns the current result set.
 int getResultSetConcurrency()
          Returns the result set concurrency to be used for this statement.
 int getResultSetHoldability()
           
 int getResultSetType()
          Returns the result set type to be used for this statement.
 int getUpdateCount()
          Returns the current update count.
 SQLWarning getWarnings()
           
 void setCursorName(String name)
           
 void setEscapeProcessing(boolean enable)
           
 void setFetchDirection(int direction)
           
 void setFetchSize(int rows)
           
 void setMaxFieldSize(int max)
           
 void setMaxRows(int max)
           
 void setQueryTimeout(int seconds)
           
 
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 statement's resources. This closes the current result set.

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

executeQuery

public ResultSet executeQuery(String sql)
                       throws JdbcMeException
Runs an SQL statement that returns a single result set. This closes the current result set and clears warnings before executing the new SQL statement.

Specified by:
executeQuery in interface Statement
Parameters:
sql - The SQL statement.
Returns:
The result set that contains the data produced by the query.
Throws:
JdbcMeException - If the statement is not open, the SQL statement contains a syntax error, no result set is returned by the database, the query timeout limit is exceeded, or an error occurs.

executeUpdate

public int executeUpdate(String sql)
                  throws JdbcMeException
Runs an SQL INSERT, UPDATE, or DELETE statement, or any SQL statement that does not return a result set. This closes the current result set and clears warnings before executing the new SQL statement.

Specified by:
executeUpdate in interface Statement
Parameters:
sql - The SQL statement.
Returns:
Either the row count for INSERT, UPDATE, or DELETE, or 0 for SQL statements that return nothing.
Throws:
JdbcMeException - If the statement is not open, the SQL statement contains a syntax error, the query timeout limit is exceeded, the statement returns a result set, or an error occurs.

execute

public boolean execute(String sql)
                throws JdbcMeException
Runs an SQL statement that may return multiple result sets. This closes the current result set and clears warnings before executing the new SQL statement.

Under some situations, a single SQL statement may return multiple result sets, an update count, or both. This might occur when executing a stored procedure that returns multiple result sets or when dynamically executing an unknown SQL string.

Use getResultSet() and getUpdateCount() to navigate through multiple result sets, an update count, or both.

Specified by:
execute in interface Statement
Parameters:
sql - The SQL statement.
Returns:
true if a result set was returned, false if an update count was returned or nothing was returned.
Throws:
JdbcMeException - If the statement is not open, the SQL statement contains a syntax error, the query timeout limit is exceeded, or an error occurs.

executeToOfflineData

public boolean executeToOfflineData(String sql,
                                    String dbName,
                                    int dbCreator,
                                    int dbType)
                             throws JdbcMeException
Create or overwrite an offline device specific database containing the results of the query specified. This offline database can be accessed without a connection to the host database server.

If the SQL statement does not generate query results, then the target offline database is not changed.

If the target offline database exists, it is destroyed and its contents are filled with the results of the query.

Use JdbcMeOfflineResultSet to access the data from the offline data at a later time (for example after disconnecting from the DB server.

 For example.
  MIDP - The 'name' is a unique string of up to 32
         unique characters identifying a
         javax.microedition.rms.RecordStore object
         the offline data object returned, then
         encapsulates the RecordStore object.

  PALM - The 'name' is effectively just a visual
         key, while the offline data is uniquely
         identified by the 'dbCreator' and the
         'dbType' parameters.
  

Parameters:
sql - The SQL statement.
dbName - The name of the offline database.
dbCreator - The unique offline database creator identifier.
dbType - The unique offline database type identifier.
Returns:
true if a result set was returned to the offline database, false if an update count was returned or nothing was returned.
Throws:
JdbcMeException - If the statement is not open, the SQL statement contains a syntax error, the query timeout limit is exceeded, or an error occurs.

getResultSet

public ResultSet getResultSet()
                       throws JdbcMeException
Returns the current result set.

Specified by:
getResultSet in interface Statement
Returns:
The current result set, or null if an update count was returned or there are no more result sets.
Throws:
JdbcMeException - If the statement is not open.

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws JdbcMeException
Returns the result set concurrency to be used for this statement.

Specified by:
getResultSetConcurrency in interface Statement
Returns:
The result set concurrency.
Throws:
JdbcMeException - If the statement is not open.

getResultSetType

public int getResultSetType()
                     throws JdbcMeException
Returns the result set type to be used for this statement.

Specified by:
getResultSetType in interface Statement
Returns:
The result set type.
Throws:
JdbcMeException - If the statement is not open.

getUpdateCount

public int getUpdateCount()
                   throws JdbcMeException
Returns the current update count.

Specified by:
getUpdateCount in interface Statement
Returns:
The update count, or -1 if a result set was returned or there are no more result sets.
Throws:
JdbcMeException - If the statement is not open.

getConnection

public Connection getConnection()
                         throws JdbcMeException
Returns the connection for this statement.

Specified by:
getConnection in interface Statement
Returns:
The connection for this statement.
Throws:
JdbcMeException - If an error occurs.

addBatch

public void addBatch(String sql)
              throws SQLException
Specified by:
addBatch in interface Statement
Throws:
SQLException

cancel

public void cancel()
            throws SQLException
Specified by:
cancel in interface Statement
Throws:
SQLException

clearBatch

public void clearBatch()
                throws SQLException
Specified by:
clearBatch in interface Statement
Throws:
SQLException

clearWarnings

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

execute

public boolean execute(String sql,
                       int autoGeneratedKeys)
                throws SQLException
Specified by:
execute in interface Statement
Throws:
SQLException

execute

public boolean execute(String sql,
                       int[] columnIndexes)
                throws SQLException
Specified by:
execute in interface Statement
Throws:
SQLException

execute

public boolean execute(String sql,
                       String[] columnNames)
                throws SQLException
Specified by:
execute in interface Statement
Throws:
SQLException

executeBatch

public int[] executeBatch()
                   throws SQLException
Specified by:
executeBatch in interface Statement
Throws:
SQLException

executeUpdate

public int executeUpdate(String sql,
                         int autoGeneratedKeys)
                  throws SQLException
Specified by:
executeUpdate in interface Statement
Throws:
SQLException

executeUpdate

public int executeUpdate(String sql,
                         int[] columnIndexes)
                  throws SQLException
Specified by:
executeUpdate in interface Statement
Throws:
SQLException

executeUpdate

public int executeUpdate(String sql,
                         String[] columnNames)
                  throws SQLException
Specified by:
executeUpdate in interface Statement
Throws:
SQLException

getFetchDirection

public int getFetchDirection()
                      throws SQLException
Specified by:
getFetchDirection in interface Statement
Throws:
SQLException

getFetchSize

public int getFetchSize()
                 throws SQLException
Specified by:
getFetchSize in interface Statement
Throws:
SQLException

getGeneratedKeys

public ResultSet getGeneratedKeys()
                           throws SQLException
Specified by:
getGeneratedKeys in interface Statement
Throws:
SQLException

getMaxFieldSize

public int getMaxFieldSize()
                    throws SQLException
Specified by:
getMaxFieldSize in interface Statement
Throws:
SQLException

getMaxRows

public int getMaxRows()
               throws SQLException
Specified by:
getMaxRows in interface Statement
Throws:
SQLException

getMoreResults

public boolean getMoreResults()
                       throws SQLException
Specified by:
getMoreResults in interface Statement
Throws:
SQLException

getMoreResults

public boolean getMoreResults(int current)
                       throws SQLException
Specified by:
getMoreResults in interface Statement
Throws:
SQLException

getQueryTimeout

public int getQueryTimeout()
                    throws SQLException
Specified by:
getQueryTimeout in interface Statement
Throws:
SQLException

getResultSetHoldability

public int getResultSetHoldability()
                            throws SQLException
Specified by:
getResultSetHoldability in interface Statement
Throws:
SQLException

getWarnings

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

setCursorName

public void setCursorName(String name)
                   throws SQLException
Specified by:
setCursorName in interface Statement
Throws:
SQLException

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws SQLException
Specified by:
setEscapeProcessing in interface Statement
Throws:
SQLException

setFetchDirection

public void setFetchDirection(int direction)
                       throws SQLException
Specified by:
setFetchDirection in interface Statement
Throws:
SQLException

setFetchSize

public void setFetchSize(int rows)
                  throws SQLException
Specified by:
setFetchSize in interface Statement
Throws:
SQLException

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws SQLException
Specified by:
setMaxFieldSize in interface Statement
Throws:
SQLException

setMaxRows

public void setMaxRows(int max)
                throws SQLException
Specified by:
setMaxRows in interface Statement
Throws:
SQLException

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws SQLException
Specified by:
setQueryTimeout in interface Statement
Throws:
SQLException