Statement

Represents a statement.

Methods
void addBatch(String sql)
Adds a statement to the batch.
void cancel()
Cancels a currently running statement.
void clearBatch()
Clears the batch.
void clearWarnings()
Clears all warnings.
void close()
Closes this statement.
void closeOldResultSet()
Close and old result set if there is still one open.
boolean execute(String sql)
Executes an arbitrary statement.
boolean execute(String sql, int autoGeneratedKeys)
Executes a statement and returns the update count.
boolean execute(String sql, int[] columnIndexes)
Executes a statement and returns the update count.
boolean execute(String sql, String[] columnNames)
Executes a statement and returns the update count.
int[] executeBatch()
Executes the batch.
ResultSet executeQuery(String sql)
Executes a query (select statement) and returns the result set.
int executeUpdate(String sql)
Executes a statement (insert, update, delete, create, drop) and returns the update count.
int executeUpdate(String sql, int autoGeneratedKeys)
Executes a statement and returns the update count.
int executeUpdate(String sql, int[] columnIndexes)
Executes a statement and returns the update count.
int executeUpdate(String sql, String[] columnNames)
Executes a statement and returns the update count.
Connection getConnection()
Returns the connection that created this object.
int getFetchDirection()
Gets the fetch direction.
int getFetchSize()
Gets the number of rows suggested to read in one step.
ResultSet getGeneratedKeys()
Return a result set that contains the last generated autoincrement key for this connection.
int getMaxFieldSize()
Gets the maximum number of bytes for a result set column.
int getMaxRows()
Gets the maximum number of rows for a ResultSet.
boolean getMoreResults()
Moves to the next result set - however there is always only one result set.
boolean getMoreResults(int current)
[Not supported]
int getQueryTimeout()
Gets the current query timeout in seconds.
ResultSet getResultSet()
Returns the last result set produces by this statement.
int getResultSetConcurrency()
Gets the result set concurrency created by this object.
int getResultSetHoldability()
Gets the result set holdability.
int getResultSetType()
Gets the result set type.
int getUpdateCount()
Returns the last update count of this statement.
SQLWarning getWarnings()
Gets the first warning reported by calls on this object.
boolean isClosed()
Returns whether this statement is closed.
boolean isPoolable()
Returns whether this object is poolable.
void setCursorName(String name)
Sets the name of the cursor.
void setEscapeProcessing(boolean enable)
Enables or disables processing or JDBC escape syntax.
void setExecutingStatement(CommandInterface c)
void setFetchDirection(int direction)
Sets the fetch direction.
void setFetchSize(int rows)
Sets the number of rows suggested to read in one step.
void setMaxFieldSize(int max)
Sets the maximum number of bytes for a result set column.
void setMaxRows(int maxRows)
Gets the maximum number of rows for a ResultSet.
void setPoolable(boolean poolable)
Requests that this object should be pooled or not.
void setQueryTimeout(int seconds)
Sets the current query timeout in seconds.

void addBatch(String sql) throws SQLException

Adds a statement to the batch.

void cancel() throws SQLException

Cancels a currently running statement. This method must be called from within another thread than the execute method.

Throws:
SQLException - if this object is closed

void clearBatch() throws SQLException

Clears the batch.

void clearWarnings() throws SQLException

Clears all warnings. As this driver does not support warnings, this call is ignored.

void close() throws SQLException

Closes this statement. All result sets that where created by this statement become invalid after calling this method.

void closeOldResultSet() throws SQLException

Close and old result set if there is still one open.

boolean execute(String sql) throws SQLException

Executes an arbitrary statement. If another result set exists for this statement, this will be closed (even if this statement fails). If the statement is a create or drop and does not throw an exception, the current transaction (if any) is committed after executing the statement. If auto commit is on, and the statement is not a select, this statement will be committed.

Returns:
true if a result set is available, false if not

boolean execute(String sql, int autoGeneratedKeys) throws SQLException

Executes a statement and returns the update count. This method just calls execute(String sql).

Parameters:
sql - the SQL statement
Returns:
the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
SQLException - if a database error occurred or a select statement was executed

boolean execute(String sql, int[] columnIndexes) throws SQLException

Executes a statement and returns the update count. This method just calls execute(String sql).

Parameters:
sql - the SQL statement
Returns:
the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
SQLException - if a database error occurred or a select statement was executed

boolean execute(String sql, String[] columnNames) throws SQLException

Executes a statement and returns the update count. This method just calls execute(String sql).

Parameters:
sql - the SQL statement
Returns:
the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
SQLException - if a database error occurred or a select statement was executed

int[] executeBatch() throws SQLException

Executes the batch.

Returns:
the array of update counts

ResultSet executeQuery(String sql) throws SQLException

Executes a query (select statement) and returns the result set. If another result set exists for this statement, this will be closed (even if this statement fails).

Returns:
the result set

int executeUpdate(String sql) throws SQLException

Executes a statement (insert, update, delete, create, drop) and returns the update count. If another result set exists for this statement, this will be closed (even if this statement fails). If the statement is a create or drop and does not throw an exception, the current transaction (if any) is committed after executing the statement. If auto commit is on, this statement will be committed.

Parameters:
sql - the SQL statement
Returns:
the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
SQLException - if a database error occurred or a select statement was executed

int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException

Executes a statement and returns the update count. This method just calls executeUpdate(String sql).

Parameters:
sql - the SQL statement
Returns:
the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
SQLException - if a database error occurred or a select statement was executed

int executeUpdate(String sql, int[] columnIndexes) throws SQLException

Executes a statement and returns the update count. This method just calls executeUpdate(String sql).

Parameters:
sql - the SQL statement
Returns:
the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
SQLException - if a database error occurred or a select statement was executed

int executeUpdate(String sql, String[] columnNames) throws SQLException

Executes a statement and returns the update count. This method just calls executeUpdate(String sql).

Parameters:
sql - the SQL statement
Returns:
the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback)
Throws:
SQLException - if a database error occurred or a select statement was executed

Connection getConnection() throws SQLException

Returns the connection that created this object.

Returns:
the connection

int getFetchDirection() throws SQLException

Gets the fetch direction.

Returns:
FETCH_FORWARD
Throws:
SQLException - if this object is closed

int getFetchSize() throws SQLException

Gets the number of rows suggested to read in one step.

Returns:
the current fetch size
Throws:
SQLException - if this object is closed

ResultSet getGeneratedKeys() throws SQLException

Return a result set that contains the last generated autoincrement key for this connection.

Returns:
the result set with one row and one column containing the key
Throws:
SQLException - if this object is closed

int getMaxFieldSize() throws SQLException

Gets the maximum number of bytes for a result set column.

Returns:
always 0 for no limit
Throws:
SQLException - if this object is closed

int getMaxRows() throws SQLException

Gets the maximum number of rows for a ResultSet.

Returns:
the number of rows where 0 means no limit
Throws:
SQLException - if this object is closed

boolean getMoreResults() throws SQLException

Moves to the next result set - however there is always only one result set. This call also closes the current result set (if there is one). Returns true if there is a next result set (that means - it always returns false).

Returns:
false
Throws:
SQLException - if this object is closed.

boolean getMoreResults(int current) throws SQLException

[Not supported]

int getQueryTimeout() throws SQLException

Gets the current query timeout in seconds. This method will return 0 if no query timeout is set. The result is rounded to the next second.

Returns:
the timeout in seconds
Throws:
SQLException - if this object is closed

ResultSet getResultSet() throws SQLException

Returns the last result set produces by this statement.

Returns:
the result set

int getResultSetConcurrency() throws SQLException

Gets the result set concurrency created by this object.

Returns:
ResultSet.CONCUR_UPDATABLE
Throws:
SQLException - if this object is closed

int getResultSetHoldability() throws SQLException

Gets the result set holdability.

Returns:
the holdability

int getResultSetType() throws SQLException

Gets the result set type.

Returns:
the type
Throws:
SQLException - if this object is closed

int getUpdateCount() throws SQLException

Returns the last update count of this statement.

Returns:
the update count (number of row affected by an insert, update or delete, or 0 if no rows or the statement was a create, drop, commit or rollback; -1 if the statement was a select).
Throws:
SQLException - if this object is closed or invalid

SQLWarning getWarnings() throws SQLException

Gets the first warning reported by calls on this object. This driver does not support warnings, and will always return null.

Returns:
null

boolean isClosed() throws SQLException

Returns whether this statement is closed.

Returns:
true if the statement is closed

boolean isPoolable()

Returns whether this object is poolable.

Returns:
false

void setCursorName(String name) throws SQLException

Sets the name of the cursor. This call is ignored.

Parameters:
name - ignored
Throws:
SQLException - if this object is closed

void setEscapeProcessing(boolean enable) throws SQLException

Enables or disables processing or JDBC escape syntax. See also Connection.nativeSQL.

Parameters:
enable - - true (default) or false (no conversion is attempted)
Throws:
SQLException - if this object is closed

void setExecutingStatement(CommandInterface c)


void setFetchDirection(int direction) throws SQLException

Sets the fetch direction. This call is ignored by this driver.

Parameters:
direction - ignored
Throws:
SQLException - if this object is closed

void setFetchSize(int rows) throws SQLException

Sets the number of rows suggested to read in one step. This value cannot be higher than the maximum rows (setMaxRows) set by the statement or prepared statement, otherwise an exception is throws. Setting the value to 0 will set the default value. The default value can be changed using the system property h2.serverResultSetFetchSize.

Parameters:
rows - the number of rows
Throws:
SQLException - if this object is closed

void setMaxFieldSize(int max) throws SQLException

Sets the maximum number of bytes for a result set column. This method does currently do nothing for this driver.

Parameters:
max - the maximum size - ignored
Throws:
SQLException - if this object is closed

void setMaxRows(int maxRows) throws SQLException

Gets the maximum number of rows for a ResultSet.

Parameters:
maxRows - the number of rows where 0 means no limit
Throws:
SQLException - if this object is closed

void setPoolable(boolean poolable)

Requests that this object should be pooled or not. This call is ignored.

Parameters:
poolable - the requested value

void setQueryTimeout(int seconds) throws SQLException

Sets the current query timeout in seconds. Calling this method will commit an open transaction, even if the value is the same as before. Changing the value will affect all statements of this connection. This method does not commit a transaction, and rolling back a transaction does not affect this setting.

Parameters:
seconds - the timeout in seconds - 0 means no timeout, values smaller 0 will throw an exception
Throws:
SQLException - if this object is closed