Top Description Fields Constructors Methods
org.hsqldb.jdbc

public Class JDBCStatement

extends JDBCStatementBase
implements Statement, Wrapper
Class Inheritance
All Implemented Interfaces
java.sql.Wrapper, java.sql.Statement, java.lang.AutoCloseable
Imports
java.sql.BatchUpdateException, .Connection, .DatabaseMetaData, .ResultSet, .SQLException, .SQLFeatureNotSupportedException, .SQLWarning, .SQLTimeoutException, .Statement, org.hsqldb.HsqlException, .StatementTypes, org.hsqldb.navigator.RowSetNavigator, org.hsqldb.result.Result, .ResultConstants, .ResultProperties

The object used for executing a static SQL statement and returning the results it produces.

By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a current ResultSet object of the statement if an open one exists.

HSQLDB-Specific Information:

From version 2.0, the implementation meets the JDBC specification requirement that any existing ResultSet is closed when execute() or executeQuery() methods are called. The connection property close_result=true is required for this behaviour.

Methods added in JAVA 8 are generally supported.

(fredt@users)
(campbell-burnet@users)

Authors
Campbell Burnet (campbell-burnet@users dot sourceforge.net), Fred Toussi (fredt@users dot sourceforge.net)
Since
HSQLDB 1.9.0
Version
2.7.3
See Also
JDBCConnection#createStatement, JDBCResultSet

Field Summary

Modifier and TypeField and Description
pack-priv boolean
public static final int
Inherited from org.hsqldb.jdbc.JDBCStatementBase:
batchResultOutCLOSE_ALL_RESULTSCLOSE_CURRENT_RESULTconnectionconnectionIncarnationcurrentResultSeterrorResultEXECUTE_FAILEDfetchDirectionfetchSizegeneratedResultgeneratedResultSetisClosedisEscapeProcessingKEEP_CURRENT_RESULTmaxRowsNO_GENERATED_KEYSqueryTimeoutresultInresultOutRETURN_GENERATED_KEYSrootWarningrsPropertiesSUCCESS_NO_INFO

Constructor Summary

AccessConstructor and Description
pack-priv
JDBCStatement(JDBCConnection
the connection on which this statement will execute
c
,
int props)

Constructs a new JDBCStatement with the specified connection and result type.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addBatch(String
typically this is a SQL INSERT or UPDATE statement
sql
)

Implements java.sql.Statement.addBatch.

Adds the given SQL command to the current list of commands for this Statement object.

public void
cancel()

Implements java.sql.Statement.cancel.

Cancels this Statement object if both the DBMS and driver support aborting an SQL statement.

public synchronized void
clearBatch()

Implements java.sql.Statement.clearBatch.

Empties this Statement object's current list of SQL commands.

public synchronized void
clearWarnings()

Implements java.sql.Statement.clearWarnings.

Clears all the warnings reported on this Statement object.

public synchronized void
close()

Overrides org.hsqldb.jdbc.JDBCStatementBase.close.

Implements java.sql.Statement.close.

Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.

public synchronized boolean

Returns:

true if the first result is a ResultSet object; false if it is an update count or there are no results
execute
(String
any SQL statement
sql
)

Implements java.sql.Statement.execute.

Executes the given SQL statement, which may return multiple results.

public synchronized boolean

Returns:

true if the first result is a ResultSet object; false if it is an update count or there are no results
execute
(String
any SQL statement
sql
,
int
a constant indicating whether auto-generated keys should be made available for retrieval using the method getGeneratedKeys; one of the following constants: Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS
autoGeneratedKeys
)

Implements java.sql.Statement.execute.

Executes the given SQL statement, which may return multiple results, and signals the driver that any auto-generated keys should be made available for retrieval.

public synchronized boolean

Returns:

true if the first result is a ResultSet object; false if it is an update count or there are no results
execute
(String
any SQL statement
sql
,
int[]
an array of the indexes of the columns in the inserted row that should be made available for retrieval by a call to the method getGeneratedKeys
columnIndexes
)

Implements java.sql.Statement.execute.

Executes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.

public synchronized boolean

Returns:

true if the next result is a ResultSet object; false if it is an update count or there are no more results
execute
(String
any SQL statement
sql
,
String[]
an array of the names of the columns in the inserted row that should be made available for retrieval by a call to the method getGeneratedKeys
columnNames
)

Implements java.sql.Statement.execute.

Executes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.

public synchronized int[]

Returns:

an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch.
executeBatch
()

Implements java.sql.Statement.executeBatch.

Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.

public long[]

Returns:

an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch.
executeLargeBatch
()

Overrides default java.sql.Statement.executeLargeBatch.

Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.

public long

Returns:

either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
executeLargeUpdate
(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
)

Overrides default java.sql.Statement.executeLargeUpdate.

Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.

public long

Returns:

either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
executeLargeUpdate
(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
int
a flag indicating whether auto-generated keys should be made available for retrieval; one of the following constants: Statement.RETURN_GENERATED_KEYS Statement.NO_GENERATED_KEYS
autoGeneratedKeys
)

Overrides default java.sql.Statement.executeLargeUpdate.

Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement object should be made available for retrieval.

public long

Returns:

either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
executeLargeUpdate
(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
int[]
an array of column indexes indicating the columns that should be returned from the inserted row
columnIndexes
)

Overrides default java.sql.Statement.executeLargeUpdate.

Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.

public long

Returns:

either the row count for INSERT, UPDATE, or DELETE statements, or 0 for SQL statements that return nothing
executeLargeUpdate
(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
String[]
an array of the names of the columns that should be returned from the inserted row
columnNames
)

Overrides default java.sql.Statement.executeLargeUpdate.

Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.

public synchronized ResultSet

Returns:

a ResultSet object that contains the data produced by the given query; never null
executeQuery
(String
an SQL statement to be sent to the database, typically a static SQL SELECT statement
sql
)

Implements java.sql.Statement.executeQuery.

Executes the given SQL statement, which returns a single ResultSet object.

public synchronized int

Returns:

either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
executeUpdate
(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
)

Implements java.sql.Statement.executeUpdate.

Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.

public synchronized int

Returns:

either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
executeUpdate
(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
int
a flag indicating whether auto-generated keys should be made available for retrieval; one of the following constants: Statement.RETURN_GENERATED_KEYS Statement.NO_GENERATED_KEYS
autoGeneratedKeys
)

Implements java.sql.Statement.executeUpdate.

Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement object should be made available for retrieval.

public synchronized int

Returns:

either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
executeUpdate
(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
int[]
an array of column indexes indicating the columns that should be returned from the inserted row
columnIndexes
)

Implements java.sql.Statement.executeUpdate.

Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.

public synchronized int

Returns:

either the row count for INSERT, UPDATE, or DELETE statements, or 0 for SQL statements that return nothing
executeUpdate
(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
String[]
an array of the names of the columns that should be returned from the inserted row
columnNames
)

Implements java.sql.Statement.executeUpdate.

Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.

private void
fetchResult(String
a character sequence representing the SQL to be executed
sql
,
int
int
statementRetType
,
int
int
generatedKeys
,
int[]
int[]
generatedIndexes
,
String[]
String[]
generatedNames
)

Internal result producer for JDBCStatement (sqlExecDirect mode).

public synchronized Connection

Returns:

the connection that produced this statement
getConnection
()

Implements java.sql.Statement.getConnection.

Retrieves the Connection object that produced this Statement object.

public int

Returns:

the default fetch direction for result sets generated from this Statement object
getFetchDirection
()

Implements java.sql.Statement.getFetchDirection.

Retrieves the direction for fetching rows from database tables that is the default for result sets generated from this Statement object.

public synchronized int

Returns:

the default fetch size for result sets generated from this Statement object
getFetchSize
()

Implements java.sql.Statement.getFetchSize.

Retrieves the number of result set rows that is the default fetch size for ResultSet objects generated from this Statement object.

public synchronized ResultSet

Returns:

a ResultSet object containing the auto-generated key(s) generated by the execution of this Statement object
getGeneratedKeys
()

Implements java.sql.Statement.getGeneratedKeys.

Retrieves any auto-generated keys created as a result of executing this Statement object.

public long

Returns:

the current maximum number of rows for a ResultSet object produced by this Statement object; zero means there is no limit
getLargeMaxRows
()

Overrides default java.sql.Statement.getLargeMaxRows.

Retrieves the maximum number of rows that a ResultSet object produced by this Statement object can contain.

public long

Returns:

the current result as an update count; -1 if the current result is a ResultSet object or there are no more results
getLargeUpdateCount
()

Overrides default java.sql.Statement.getLargeUpdateCount.

Retrieves the current result as an update count; if the result is a ResultSet object or there are no more results, -1 is returned.

public synchronized int

Returns:

the current column size limit for columns storing character and binary values; zero means there is no limit
getMaxFieldSize
()

Implements java.sql.Statement.getMaxFieldSize.

Retrieves the maximum number of bytes that can be returned for character and binary column values in a ResultSet object produced by this Statement object.

public synchronized int

Returns:

the current maximum number of rows for a ResultSet object produced by this Statement object; zero means there is no limit
getMaxRows
()

Implements java.sql.Statement.getMaxRows.

Retrieves the maximum number of rows that a ResultSet object produced by this Statement object can contain.

public synchronized boolean

Returns:

true if the next result is a ResultSet object; false if it is an update count or there are no more results
getMoreResults
()

Overrides org.hsqldb.jdbc.JDBCStatementBase.getMoreResults.

Implements java.sql.Statement.getMoreResults.

Moves to this Statement object's next result, returns true if it is a ResultSet object, and implicitly closes any current ResultSet object(s) obtained with the method getResultSet.

public synchronized boolean

Returns:

true if the next result is a ResultSet object; false if it is an update count or there are no more results
getMoreResults
(int
one of the following Statement constants indicating what should happen to current ResultSet objects obtained using the method getResultSet: Statement.CLOSE_CURRENT_RESULT, Statement.KEEP_CURRENT_RESULT, or Statement.CLOSE_ALL_RESULTS
current
)

Overrides org.hsqldb.jdbc.JDBCStatementBase.getMoreResults.

Implements java.sql.Statement.getMoreResults.

Moves to this Statement object's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object.

public synchronized int

Returns:

the current query timeout limit in seconds; zero means there is no limit
getQueryTimeout
()

Implements java.sql.Statement.getQueryTimeout.

Retrieves the number of seconds the driver will wait for a Statement object to execute.

public synchronized ResultSet

Returns:

the current result as a ResultSet object or null if the result is an update count or there are no more results
getResultSet
()

Overrides org.hsqldb.jdbc.JDBCStatementBase.getResultSet.

Implements java.sql.Statement.getResultSet.

Retrieves the current result as a ResultSet object.

public synchronized int

Returns:

either ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
getResultSetConcurrency
()

Implements java.sql.Statement.getResultSetConcurrency.

Retrieves the result set concurrency for ResultSet objects generated by this Statement object.

public synchronized int

Returns:

either ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
getResultSetHoldability
()

Implements java.sql.Statement.getResultSetHoldability.

Retrieves the result set holdability for ResultSet objects generated by this Statement object.

public int
public synchronized int

Returns:

one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
getResultSetType
()

Implements java.sql.Statement.getResultSetType.

Retrieves the result set type for ResultSet objects generated by this Statement object.

public synchronized int

Returns:

the current result as an update count; -1 if the current result is a ResultSet object or there are no more results
getUpdateCount
()

Overrides org.hsqldb.jdbc.JDBCStatementBase.getUpdateCount.

Implements java.sql.Statement.getUpdateCount.

Retrieves the current result as an update count; if the result is a ResultSet object or there are no more results, -1 is returned.

public synchronized SQLWarning

Returns:

the first SQLWarning object or null if there are no warnings
getWarnings
()

Implements java.sql.Statement.getWarnings.

Retrieves the first warning reported by calls on this Statement object.

public synchronized boolean

Returns:

true if this Statement object is closed; false if it is still open
isClosed
()

Implements java.sql.Statement.isClosed.

Retrieves whether this Statement object has been closed.

public synchronized boolean

Returns:

true if the Statement will be closed when all of its dependent result sets are closed; false otherwise
isPoolable
()

Implements java.sql.Statement.isPoolable.

Returns a value indicating whether this Statement will be closed when all its dependent result sets are closed.

public boolean

Returns:

true if this implements the interface or directly or indirectly wraps an object that does.
isWrapperFor
(Class<?>
a Class defining an interface.
iface
)

Implements java.sql.Wrapper.isWrapperFor.

Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.

public void
setCursorName(String
the new cursor name, which must be unique within a connection
name
)

Implements java.sql.Statement.setCursorName.

Sets the SQL cursor name to the given String, which will be used by subsequent Statement object execute methods.

public void
setEscapeProcessing(boolean
true to enable escape processing; false to disable it
enable
)

Implements java.sql.Statement.setEscapeProcessing.

Sets escape processing on or off.

public synchronized void
setFetchDirection(int
the initial direction for processing rows
direction
)

Implements java.sql.Statement.setFetchDirection.

Gives the driver a hint as to the direction in which rows will be processed in ResultSet objects created using this Statement object.

public synchronized void
setFetchSize(int
the number of rows to fetch
rows
)

Implements java.sql.Statement.setFetchSize.

Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for ResultSet objects generated by this Statement.

public void
setLargeMaxRows(long
the new max rows limit; zero means there is no limit
max
)

Overrides default java.sql.Statement.setLargeMaxRows.

Sets the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the given number.

public void
setMaxFieldSize(int
the new column size limit in bytes; zero means there is no limit
max
)

Implements java.sql.Statement.setMaxFieldSize.

Sets the limit for the maximum number of bytes in a ResultSet Sets the limit for the maximum number of bytes that can be returned for character and binary column values in a ResultSet object produced by this Statement object.

public synchronized void
setMaxRows(int
the new max rows limit; zero means there is no limit
max
)

Implements java.sql.Statement.setMaxRows.

Sets the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the given number.

public synchronized void
setPoolable(boolean
requests that the statement be pooled if true and that the statement not be pooled if false
poolable
)

Implements java.sql.Statement.setPoolable.

Requests that a Statement be pooled or not pooled.

public void
setQueryTimeout(int
the new query timeout limit in seconds; zero means there is no limit
seconds
)

Implements java.sql.Statement.setQueryTimeout.

Sets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds.

public <T> T

Returns:

an object that implements the interface. May be a proxy for the actual implementing object.
unwrap
(Class<T>
A Class defining an interface that the result must implement.
iface
)

Implements java.sql.Wrapper.unwrap.

Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.

Inherited from org.hsqldb.jdbc.JDBCStatementBase:
checkClosedcloseOnCompletioncloseResultDatagetGeneratedResultSetisCloseOnCompletionperformPostExecute