All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.access.AS400JDBCStatement

java.lang.Object
   |
   +----com.ibm.as400.access.AS400JDBCStatement

public class AS400JDBCStatement
extends Object
implements Statement

The AS400JDBCStatement class provides a mechanism for executing static SQL statements. Use AS400JDBCConnection.createStatement() to create new AS400JDBCStatement 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 different statements.

It is possible to run multiple statements from the same connection in different threads, but accessing a single statment from different threads can produce unexpected results. Therefore, it is safest to confine a statement to a single thread.

See Also:
AS400JDBCResultSet

Method Index

 o cancel()
Cancels the statement.
 o clearWarnings()
Clears all warnings that have been reported for the statement.
 o close()
Releases the statement's resources immediately instead of waiting for them to be automatically released.
 o execute(String)
Executes a SQL statement that may return multiple result sets.
 o executeQuery(String)
Executes a SQL statement that returns a single result set.
 o executeUpdate(String)
Executes a SQL INSERT, UPDATE, or DELETE statement, or any SQL statement that does not necessarily return a result set.
 o finalize()
Closes the statement if not explicitly closed by the caller.
 o getMaxFieldSize()
Returns the maximum field size limit for the statement.
 o getMaxRows()
Returns the maximum rows limit for the statement.
 o getMoreResults()
Returns the next result set.
 o getQueryTimeout()
Returns the query timeout limit for this statement.
 o getResultSet()
Returns the current result set.
 o getUpdateCount()
Returns the current update count.
 o getWarnings()
Returns the first warning reported for the statement.
 o setCursorName(String)
Sets the SQL cursor name that will be used by the statement.
 o setEscapeProcessing(boolean)
Sets the escape processing mode.
 o setMaxFieldSize(int)
Sets the maximum field size limit.
 o setMaxRows(int)
Sets the maximum rows limit.
 o setQueryTimeout(int)
Sets the query timeout limit.
 o toString()
Returns the statement name.

Methods

 o cancel
 public void cancel() throws SQLException
Cancels the statement. This is useful when one thread needs to cancel a statement that is being executed by another thread. This will close the current result set.

Throws: SQLException
If an error occurs.
 o clearWarnings
 public void clearWarnings() throws SQLException
Clears all warnings that have been reported for the statement. After this call, getWarnings() returns null until a new warning is reported for the statement.

Throws: SQLException
If an error occurs.
 o close
 public void close() throws SQLException
Releases the statement's resources immediately instead of waiting for them to be automatically released. This closes the current result set.

Throws: SQLException
If an error occurs.
 o execute
 public boolean execute(String sql) throws SQLException
Executes a SQL statement that may return multiple result sets. This closes the current result set 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 getMoreResults(), getResultSet(), and getUpdateCount() to navigate through multiple result sets, an update count, or both.

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: SQLException
If the statement is not open, the SQL statement contains a syntax error, the query timeout limit is exceeded, or an error occurs.
 o executeQuery
 public ResultSet executeQuery(String sql) throws SQLException
Executes a SQL statement that returns a single result set. This closes the current result set before executing the new SQL statement.

Parameters:
sql - The SQL statement.
Returns:
The result set that contains the data produced by the query.
Throws: SQLException
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.
 o executeUpdate
 public int executeUpdate(String sql) throws SQLException
Executes a SQL INSERT, UPDATE, or DELETE statement, or any SQL statement that does not necessarily return a result set. This closes the current result set before executing the new SQL 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: SQLException
If the statement is not open, the SQL statement contains a syntax error, the query timeout limit is exceeded, or an error occurs.
 o finalize
 protected void finalize() throws Throwable
Closes the statement if not explicitly closed by the caller.

Throws: Throwable
If an error occurs.
Overrides:
finalize in class Object
 o getMaxFieldSize
 public int getMaxFieldSize() throws SQLException
Returns the maximum field size limit for the statement. The maximum field size limit is the maximum amount of data returned for any column value. It applies only to BINARY, VARBINARY, CHAR, and VARCHAR fields. If the limit is exceeded, then the excess data is discarded.

Returns:
The maximum field size limit (in bytes), or 0 for no limit.
Throws: SQLException
If the statement is not open.
See Also:
setMaxFieldSize
 o getMaxRows
 public int getMaxRows() throws SQLException
Returns the maximum rows limit for the statement. The maximum rows limit is the maximum number of rows that a result set can contain. If the limit is exceeded, then the excess rows are dropped.

Returns:
The maximum rows limit, or 0 for no limit.
Throws: SQLException
If the statement is not open.
See Also:
setMaxRows
 o getMoreResults
 public boolean getMoreResults() throws SQLException
Returns the next result set. This closes the current result set.

Returns:
true if another result set is available, false if there are no more result sets.
Throws: SQLException
If an error occurs.
 o getQueryTimeout
 public int getQueryTimeout() throws SQLException
Returns the query timeout limit for this statement. The query timeout limit is the number of seconds that the driver will wait for a SQL statement to execute.

Returns:
The query timeout limit (in seconds), or 0 for no limit.
Throws: SQLException
If the statement is not open.
See Also:
setQueryTimeout
 o getResultSet
 public ResultSet getResultSet() throws SQLException
Returns the current result set.

Returns:
The current result set, or null if an update count was returned or there are no more result sets.
Throws: SQLException
If the statement is not open.
 o getUpdateCount
 public int getUpdateCount() throws SQLException
Returns the current update count.

Returns:
The update count, or -1 if a result set was returned or there are no more result sets.
Throws: SQLException
If the statement is not open.
 o getWarnings
 public SQLWarning getWarnings() throws SQLException
Returns the first warning reported for the statement. 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 setCursorName
 public void setCursorName(String name) throws SQLException
Sets the SQL cursor name that will be used by the statement. Cursor names must be unique within the connection. The cursor name can only be set when no result set is open.

The cursor name can be used in SQL positioned UPDATE or DELETE statements to identify the current row in the result set generated by this statement. By definition, SQL positioned UPDATEs or DELETEs must be executed by a different statement than the one that generated the result set being used for positioning.

Parameters:
name - The cursor name. If null, a unique default name will be used.
Throws: SQLException
If the statement is not open, a result set is open, the cursor name is not unique within the connection, or an error occurs.
See Also:
getCursorName
 o setEscapeProcessing
 public void setEscapeProcessing(boolean enable) throws SQLException
Sets the escape processing mode. When processing escape clauses, the JDBC driver substitutes escape clauses in SQL statements with DB2 for OS/400 SQL grammar elements. If escape processing is not needed, then setting the escape processing mode to false improves performance. The default is to process escape clauses.

Parameters:
enable - true to process escape clauses; false otherwise.
Throws: SQLException
If the statement is not open.
 o setMaxFieldSize
 public void setMaxFieldSize(int max) throws SQLException
Sets the maximum field size limit. The maximum field size limit is the maximum amount of data returned for any column value. It applies only to BINARY, VARBINARY, CHAR, and VARCHAR fields. If the limit is exceeded, then the excess data is discarded. The default is 0 (no limit).

Parameters:
max - The maximum field size limit (in bytes) or 0 for no limit.
Throws: SQLException
If the statement is not open or the input value is not valid.
See Also:
getMaxFieldSize
 o setMaxRows
 public void setMaxRows(int max) throws SQLException
Sets the maximum rows limit. The maximum rows limit is the maximum number of rows that a result set can contain. If the limit is exceeded, the excess rows are dropped. The default is 0 (no limit).

Parameters:
max - The maximum rows limit or 0 for no limit.
Throws: SQLException
If the statement is not open or the input value is not valid.
See Also:
getMaxRows
 o setQueryTimeout
 public void setQueryTimeout(int seconds) throws SQLException
Sets the query timeout limit. The query timeout limit is the number of seconds that the driver will wait for a SQL statement to execute. The default is 0 (no limit).

Parameters:
seconds - The query timeout limit (in seconds) or 0 for no limit.
Throws: SQLException
If the statement is not open or the input value is not valid.
See Also:
getQueryTimeout
 o toString
 public String toString()
Returns the statement name.

Returns:
The statement name.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index