com.ibm.as400.micro
Class JdbcMeStatement

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

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
Modifier and Type Field and Description
 
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
Modifier and Type Method and Description
 void close()
          Releases the statement's resources.
 boolean execute(String sql)
          Runs an SQL statement that may return multiple result sets.
 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.
 Connection getConnection()
          Returns the connection for this statement.
 ResultSet getResultSet()
          Returns the current result set.
 int getResultSetConcurrency()
          Returns the result set concurrency to be used for this statement.
 int getResultSetType()
          Returns the result set type to be used for this statement.
 int getUpdateCount()
          Returns the current update count.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.sql.Statement
addBatch, cancel, clearBatch, clearWarnings, execute, execute, execute, executeBatch, executeUpdate, executeUpdate, executeUpdate, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSetHoldability, getWarnings, isClosed, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

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.