# 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]
String | enquoteIdentifier(String identifier, boolean alwaysQuote)
String | enquoteIdentifier(String identifier, boolean alwaysQuote) throws SQLException Parameters: identifier - identifier to quote if required, may be quoted or unquoted alwaysQuote - if {@code true} identifier will be quoted unconditionally Returns: specified identifier quoted if required, explicitly requested, or if it was already quoted Throws: SQLException - if identifier is not a valid identifier
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. Parameters: sql - the SQL statement autoGeneratedKeys - {@link Statement#RETURN_GENERATED_KEYS} if generated keys should be available for retrieval, {@link Statement#NO_GENERATED_KEYS} if generated keys should not be available 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. Parameters: sql - the SQL statement columnIndexes - an array of column indexes indicating the columns with generated keys that should be returned from the inserted row 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. Parameters: sql - the SQL statement columnNames - an array of column names indicating the columns with generated keys that should be returned from the inserted row 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
long[] | executeLargeBatch() Executes the batch.
long[] | executeLargeBatch() throws SQLException Executes the batch. If one of the batched statements fails, this database will continue. Returns: the array of update counts
long | executeLargeUpdate(String sql) Executes a statement (insert, update, delete, create, drop) and returns the update count.
long | executeLargeUpdate(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
long | executeLargeUpdate(String sql, int autoGeneratedKeys) Executes a statement and returns the update count.
long | executeLargeUpdate(String sql, int autoGeneratedKeys) throws SQLException Executes a statement and returns the update count. Parameters: sql - the SQL statement autoGeneratedKeys - {@link Statement#RETURN_GENERATED_KEYS} if generated keys should be available for retrieval, {@link Statement#NO_GENERATED_KEYS} if generated keys should not be available 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
long | executeLargeUpdate(String sql, int[] columnIndexes) Executes a statement and returns the update count.
long | executeLargeUpdate(String sql, int[] columnIndexes) throws SQLException Executes a statement and returns the update count. Parameters: sql - the SQL statement columnIndexes - an array of column indexes indicating the columns with generated keys that should be returned from the inserted row 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
long | executeLargeUpdate(String sql, String[] columnNames) Executes a statement and returns the update count.
long | executeLargeUpdate(String sql, String[] columnNames) throws SQLException Executes a statement and returns the update count. Parameters: sql - the SQL statement columnNames - an array of column names indicating the columns with generated keys that should be returned from the inserted row 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
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. Parameters: sql - the SQL statement autoGeneratedKeys - {@link Statement#RETURN_GENERATED_KEYS} if generated keys should be available for retrieval, {@link Statement#NO_GENERATED_KEYS} if generated keys should not be available 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. Parameters: sql - the SQL statement columnIndexes - an array of column indexes indicating the columns with generated keys that should be returned from the inserted row 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. Parameters: sql - the SQL statement columnNames - an array of column names indicating the columns with generated keys that should be returned from the inserted row 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 with generated keys from the latest executed command or an empty result set if keys were not generated or were not requested with
ResultSet | getGeneratedKeys() throws SQLException Return a result set with generated keys from the latest executed command or an empty result set if keys were not generated or were not requested with {@link Statement#RETURN_GENERATED_KEYS}, column indexes, or column names. Generated keys are only returned from inserted rows from {@code INSERT}, {@code MERGE INTO}, and {@code MERGE INTO ... USING} commands. Generated keys are not returned if exact values of generated columns were specified explicitly in SQL command. All columns with inserted generated values are included in the result if command was executed with {@link Statement#RETURN_GENERATED_KEYS} parameter. If SQL command inserts multiple rows with generated keys each such inserted row is returned. Batch methods are also supported. When multiple rows are returned each row contains only generated values for this row. It's possible to insert several rows with generated values in different columns with some specific commands, in this special case the returned result set contains all used columns, but each row will contain only generated values, columns that were not generated for this row will contain {@code null} values. H2 treats inserted value as generated in the following cases: Columns with sequences including {@code IDENTITY} columns and columns with {@code AUTO_INCREMENT} if value was generated automatically (not specified in command). Columns with other default values that are not evaluated into constant expressions (like {@code DEFAULT RANDOM_UUID()}) also only if default value was inserted. Columns that were set by triggers. Columns with values specified in command with invocation of some sequence (like {@code INSERT INTO ... VALUES (NEXT VALUE FOR ...)}). Exact required columns for the returning result set may be specified on execution of command with names or indexes of columns to limit output or reorder columns in result set. Specifying of some column has no effect on treatment of inserted values as generated or not. If some value is not determined to be generated it will not be returned even on explicit request. Returns: the possibly empty result set with generated keys Throws: SQLException - if this object is closed
long | getLargeMaxRows() Gets the maximum number of rows for a ResultSet.
long | getLargeMaxRows() 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
long | getLargeUpdateCount() Returns the last update count of this statement.
long | getLargeUpdateCount() 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
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 | isSimpleIdentifier(String identifier)
boolean | isSimpleIdentifier(String identifier) throws SQLException Parameters: identifier - identifier to check Returns: is specified identifier may be used without quotes
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 | setLargeMaxRows(long maxRows) Gets the maximum number of rows for a ResultSet.
void | setLargeMaxRows(long 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 | 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