Statement

Represents a statement.

Methods
void addBatch(String sql)
Adds a statement to the batch.
void addBatch(String sql) throws SQLException
Adds a statement to the batch.
Parameters:
sql - the SQL statement
void cancel()
Cancels a currently running statement.
void cancel() throws SQLException
Cancels a currently running statement. This method must be called from within another thread than the execute method. Operations on large objects are not interrupted, only operations that process many rows.
Throws:
SQLException - if this object is closed
void clearBatch()
Clears the batch.
void clearBatch() throws SQLException
Clears the batch.
void clearWarnings()
Clears all warnings.
void clearWarnings() throws SQLException
Clears all warnings. As this driver does not support warnings, this call is ignored.
void close()
Closes this statement.
void close() throws SQLException
Closes this statement. All result sets that where created by this statement become invalid after calling this method.
void closeOnCompletion()
[Not supported]
void closeOnCompletion()
[Not supported]
boolean execute(String sql)
Executes an arbitrary statement.
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.
Parameters:
sql - the SQL statement to execute
Returns:
true if a result set is available, false if not
boolean execute(String sql, int autoGeneratedKeys)
Executes a statement and returns the update count.
boolean execute(String sql, int autoGeneratedKeys) throws SQLException
Executes a statement and returns the update count. This method just calls execute(String sql) internally. The method getGeneratedKeys supports at most one columns and row.
Parameters:
sql - the SQL statement
autoGeneratedKeys - ignored
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)
Executes a statement and returns the update count.
boolean execute(String sql, int[] columnIndexes) throws SQLException
Executes a statement and returns the update count. This method just calls execute(String sql) internally. The method getGeneratedKeys supports at most one columns and row.
Parameters:
sql - the SQL statement
columnIndexes - ignored
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)
Executes a statement and returns the update count.
boolean execute(String sql, String[] columnNames) throws SQLException
Executes a statement and returns the update count. This method just calls execute(String sql) internally. The method getGeneratedKeys supports at most one columns and row.
Parameters:
sql - the SQL statement
columnNames - ignored
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()
Executes the batch.
int[] executeBatch() throws SQLException
Executes the batch. If one of the batched statements fails, this database will continue.
Returns:
the array of update counts
ResultSet executeQuery(String sql)
Executes a query (select statement) and returns the result set.
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).
Parameters:
sql - the SQL statement to execute
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) 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 auto commit is on, this statement will be committed. If the statement is a DDL statement (create, drop, alter) and does not throw an exception, the current transaction (if any) is committed after executing the statement.
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)
Executes a statement and returns the update count.
int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
Executes a statement and returns the update count. This method just calls executeUpdate(String sql) internally. The method getGeneratedKeys supports at most one columns and row.
Parameters:
sql - the SQL statement
autoGeneratedKeys - ignored
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)
Executes a statement and returns the update count.
int executeUpdate(String sql, int[] columnIndexes) throws SQLException
Executes a statement and returns the update count. This method just calls executeUpdate(String sql) internally. The method getGeneratedKeys supports at most one columns and row.
Parameters:
sql - the SQL statement
columnIndexes - ignored
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)
Executes a statement and returns the update count.
int executeUpdate(String sql, String[] columnNames) throws SQLException
Executes a statement and returns the update count. This method just calls executeUpdate(String sql) internally. The method getGeneratedKeys supports at most one columns and row.
Parameters:
sql - the SQL statement
columnNames - ignored
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()
Returns the connection that created this object.
Connection getConnection()
Returns the connection that created this object.
Returns:
the connection
int getFetchDirection()
Gets the fetch direction.
int getFetchDirection() throws SQLException
Gets the fetch direction.
Returns:
FETCH_FORWARD
Throws:
SQLException - if this object is closed
int getFetchSize()
Gets the number of rows suggested to read in one step.
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()
Return a result set that contains the last generated auto-increment key for this connection, if there was one.
ResultSet getGeneratedKeys() throws SQLException
Return a result set that contains the last generated auto-increment key for this connection, if there was one. If no key was generated by the last modification statement, then an empty result set is returned. The returned result set only contains the data for the very last row.
Returns:
the result set with one row and one column containing the key
Throws:
SQLException - if this object is closed
int getMaxFieldSize()
Gets the maximum number of bytes for a result set column.
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()
Gets the maximum number of rows for a ResultSet.
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()
Moves to the next result set - however there is always only one result set.
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)
Move to the next result set.
boolean getMoreResults(int current) throws SQLException
Move to the next result set. This method always returns false.
Parameters:
current - Statement.CLOSE_CURRENT_RESULT, Statement.KEEP_CURRENT_RESULT, or Statement.CLOSE_ALL_RESULTS
Returns:
false
int getQueryTimeout()
Gets the current query timeout in seconds.
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. For performance reasons, only the first call to this method will query the database. If the query timeout was changed in another way than calling setQueryTimeout, this method will always return the last value.
Returns:
the timeout in seconds
Throws:
SQLException - if this object is closed
ResultSet getResultSet()
Returns the last result set produces by this statement.
ResultSet getResultSet() throws SQLException
Returns the last result set produces by this statement.
Returns:
the result set
int getResultSetConcurrency()
Gets the result set concurrency created by this object.
int getResultSetConcurrency() throws SQLException
Gets the result set concurrency created by this object.
Returns:
the concurrency
int getResultSetHoldability()
Gets the result set holdability.
int getResultSetHoldability() throws SQLException
Gets the result set holdability.
Returns:
the holdability
int getResultSetType()
Gets the result set type.
int getResultSetType() throws SQLException
Gets the result set type.
Returns:
the type
Throws:
SQLException - if this object is closed
int getUpdateCount()
Returns the last update count of this statement.
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()
Gets the first warning reported by calls on this object.
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 isCancelled()
Check whether the statement was cancelled.
boolean isCancelled()
Check whether the statement was cancelled.
Returns:
true if yes
boolean isCloseOnCompletion()
[Not supported]
boolean isCloseOnCompletion()
[Not supported]
boolean isClosed()
Returns whether this statement is closed.
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.
boolean isPoolable()
Returns whether this object is poolable.
Returns:
false
boolean isWrapperFor(Class iface)
Checks if unwrap can return an object of this class.
boolean isWrapperFor(Class iface) throws SQLException
Checks if unwrap can return an object of this class.
Parameters:
iface - the class
Returns:
whether or not the interface is assignable from this class
void setCursorName(String name)
Sets the name of the cursor.
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)
Enables or disables processing or JDBC escape syntax.
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 setFetchDirection(int direction)
Sets the fetch direction.
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)
Sets the number of rows suggested to read in one step.
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)
Sets the maximum number of bytes for a result set column.
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)
Gets the maximum number of rows for a ResultSet.
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.
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)
Sets the current query timeout in seconds.
void setQueryTimeout(int seconds) throws SQLException
Sets the current query timeout in seconds. 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
T unwrap(Class iface)
Return an object of this class if possible.
T unwrap(Class iface) throws SQLException
Return an object of this class if possible.
Parameters:
iface - the class
Returns:
this