Class EmbedStatement
- All Implemented Interfaces:
AutoCloseable
,Statement
,Wrapper
,EngineStatement
- Direct Known Subclasses:
EmbedPreparedStatement
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final Connection
protected EngineStatement
Statement reference the application is using to execute this Statement.private ResultSet
private boolean
private boolean
private int
private String
private EmbedResultSet[]
private int
private int
private final boolean
protected boolean
(package private) final LanguageConnectionContext
(package private) int
(package private) long
private ParameterValueSet
(package private) EmbedResultSet
(package private) final int
private final int
(package private) final int
(package private) String
(package private) long
Query timeout in milliseconds.(package private) long
private SQLWarning
Fields inherited from class org.apache.derby.impl.jdbc.ConnectionChild
factory, localConn
Fields inherited from interface java.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
-
Constructor Summary
ConstructorsConstructorDescriptionEmbedStatement
(EmbedConnection connection, boolean forMetaData, int resultSetType, int resultSetConcurrency, int resultSetHoldability) -
Method Summary
Modifier and TypeMethodDescriptionvoid
JDBC 2.0 Adds a SQL command to the current batch of commmands for the statement.(package private) final void
addWarning
(SQLWarning sw) Add a SQLWarning to this Statement object.void
cancel()
Cancel can be used by one thread to cancel a statement that is being executed by another thread.(package private) final void
A heavier weight version of checkStatus() that ensures the application's Connection object is still open.(package private) final void
(package private) void
checkRequiresCallableStatement
(Activation activation) Check to see if a statement requires to be executed via a callable statement.(package private) final void
Throw an exception if this Statement has been closed explictly or it has noticed it has been closed implicitly.final void
JDBC 2.0 Make the set of commands in the current batch empty.(package private) void
Close and clear all result sets associated with this statement from the last execution.private void
void
After this call getWarnings returns null until a new warning is reported for this Statement.final void
close()
In many cases, it is desirable to immediately release a Statements's database and JDBC resources instead of waiting for this to happen when it is automatically closed; the close method provides this immediate release.(package private) void
(package private) void
void
boolean
Execute a SQL statement that may return multiple results.private boolean
execute
(String sql, boolean executeQuery, boolean executeUpdate, int autoGeneratedKeys, int[] columnIndexes, String[] columnNames) Execute a SQL statement that may return multiple results.boolean
JDBC 3.0 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.boolean
JDBC 3.0 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.boolean
JDBC 3.0 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.int[]
JDBC 2.0 Submit a batch of commands to the database for execution.(package private) boolean
executeBatchElement
(Object batchElement) Execute a single element of the batch.long[]
JDBC 4.2 Submit a batch of commands to the database for execution.long
executeLargeUpdate
(String sql) JDBC 4.2 Execute a SQL INSERT, UPDATE or DELETE statement.long
executeLargeUpdate
(String sql, int autoGeneratedKeys) JDBC 4.2 Execute 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.long
executeLargeUpdate
(String sql, int[] columnIndexes) JDBC 4.2 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.long
executeLargeUpdate
(String sql, String[] columnNames) JDBC 4.2 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.executeQuery
(String sql) Execute a SQL statement that returns a single ResultSet.(package private) boolean
executeStatement
(Activation a, boolean executeQuery, boolean executeUpdate) Execute the current statement.int
executeUpdate
(String sql) Execute a SQL INSERT, UPDATE or DELETE statement.int
executeUpdate
(String sql, int autoGeneratedKeys) JDBC 3.0 Execute 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.int
executeUpdate
(String sql, int[] columnIndexes) JDBC 3.0 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.int
executeUpdate
(String sql, String[] columnNames) JDBC 3.0 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.protected void
finalize()
Mark the statement and its single-use activation as unused.final Connection
JDBC 2.0 Return the Connection that produced the Statement.private boolean
Get the execute time holdability for the Statement.int
JDBC 2.0 Determine the fetch direction.int
JDBC 2.0 Determine the default fetch size.final ResultSet
JDBC 3.0 Retrieves any auto-generated keys created as a result of executing this Statement object.long
JDBC 4.2 The maxRows limit is the maximum number of rows that a ResultSet can contain.final long
JDBC 4.2 getLargeUpdateCount returns the current result as an update count; if the result is a ResultSet or there are no more results -1 is returned.int
The maxFieldSize limit (in bytes) is the maximum amount of data returned for any column value; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR columns.int
The maxRows limit is the maximum number of rows that a ResultSet can contain.final boolean
getMoreResults moves to a Statement's next result.final boolean
getMoreResults
(int current) JDBC 3.0 Moves to this Statement obect'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 objectfinal int
The queryTimeout limit is the number of seconds the driver will wait for a Statement to execute.final ResultSet
getResultSet returns the current result as a ResultSet.int
JDBC 2.0 Determine the result set concurrency.final int
JDBC 3.0 Retrieves the result set holdability for ResultSet objects generated by this Statement object.final int
JDBC 2.0 Determine the result set type.final int
getUpdateCount returns the current result as an update count; if the result is a ResultSet or there are no more results -1 is returned.The first warning reported by calls on this Statement is returned.boolean
isClosed()
Tell whether this statment has been closed or not.boolean
private boolean
isOpen
(EmbedResultSet rs) boolean
Returns the value of the EmbedStatement's poolable hint, indicating whether pooling is requested.final boolean
isWrapperFor
(Class<?> interfaces) Returns false unlessinterfaces
is implemented.(package private) static EmbedResultSet
processDynamicResult
(EmbedConnection conn, ResultSet resultSet, EmbedStatement callStatement) Process a ResultSet created in a Java procedure as a dynamic result.private int
processDynamicResults
(ResultSet[][] holder, int maxDynamicResultSets) Go through a holder of dynamic result sets, remove those that should not be returned, and sort the result sets according to their creation.(package private) void
resultSetClosing
(EmbedResultSet closingLRS) Callback on the statement when one of its result sets is closed.final void
Set the application statement for this Statement.void
setCursorName
(String name) setCursorName defines the SQL cursor name that will be used by subsequent Statement execute methods.void
setEscapeProcessing
(boolean enable) If escape scanning is on (the default) the driver will do escape substitution before sending the SQL to the database.void
setFetchDirection
(int direction) JDBC 2.0 Give a hint as to the direction in which the rows in a result set will be processed.void
setFetchSize
(int rows) JDBC 2.0 Give the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed.void
setLargeMaxRows
(long max) The maxRows limit is set to limit the number of rows that any ResultSet can contain.void
setMaxFieldSize
(int max) The maxFieldSize limit (in bytes) is set to limit the size of data that can be returned for any column value; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR fields.void
setMaxRows
(int max) The maxRows limit is set to limit the number of rows that any ResultSet can contain.void
setPoolable
(boolean poolable) Requests that an EmbedStatement be pooled or not.final void
setQueryTimeout
(int seconds) The queryTimeout limit is the number of seconds the driver will wait for a Statement to execute.void
transferBatch
(EmbedStatement other) Transfer my batch of Statements to a newly created Statement.final <T> T
Returnsthis
if this class implements the interface.Methods inherited from class org.apache.derby.impl.jdbc.ConnectionChild
commitIfAutoCommit, commitIfNeeded, getCal, getConnectionSynchronization, getEmbedConnection, getLanguageConnectionContext, getLCC, handleException, needCommit, newSQLException, restoreContextStack, restoreIntrFlagIfSeen, setupContextStack
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.sql.Statement
enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, isSimpleIdentifier
-
Field Details
-
applicationConnection
-
applicationStatement
Statement reference the application is using to execute this Statement. Normally set to this, but if this was created by a Connection from an XAConnection then this will be a reference to the BrokeredStatement. Making it protected to allow access from EmbedPreparedStatement40 to be used for StatementEvents -
updateCount
long updateCount -
results
EmbedResultSet results -
autoGeneratedKeysResultSet
-
cursorName
-
forMetaData
private final boolean forMetaData -
resultSetType
final int resultSetType -
resultSetConcurrency
final int resultSetConcurrency -
resultSetHoldability
private final int resultSetHoldability -
lcc
-
warnings
-
SQLText
String SQLText -
fetchSize
private int fetchSize -
fetchDirection
private int fetchDirection -
MaxFieldSize
int MaxFieldSize -
timeoutMillis
long timeoutMillisQuery timeout in milliseconds. By default, no statements time out. Timeout is set explicitly with setQueryTimeout(). -
active
private boolean active -
batchStatements
-
maxRows
long maxRows -
pvs
-
isPoolable
protected boolean isPoolable -
closeOnCompletion
private boolean closeOnCompletion -
closingResultSets
private boolean closingResultSets -
dynamicResults
-
currentDynamicResultSet
private int currentDynamicResultSet
-
-
Constructor Details
-
EmbedStatement
public EmbedStatement(EmbedConnection connection, boolean forMetaData, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
-
-
Method Details
-
executeQuery
Execute a SQL statement that returns a single ResultSet.- Specified by:
executeQuery
in interfaceStatement
- Parameters:
sql
- typically this is a static SQL SELECT statement- Returns:
- a ResultSet that contains the data produced by the query; never null
- Throws:
SQLException
- thrown on failure.
-
executeUpdate
Execute a SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing such as SQL DDL statements can be executed.- Specified by:
executeUpdate
in interfaceStatement
- Parameters:
sql
- a SQL INSERT, UPDATE or DELETE statement or a SQL statement that returns nothing- Returns:
- either the row count for INSERT, UPDATE or DELETE; or 0 for SQL statements that return nothing
- Throws:
SQLException
- thrown on failure.
-
executeLargeUpdate
JDBC 4.2 Execute a SQL INSERT, UPDATE or DELETE statement. For use with statements which may touch more than Integer.MAX_VALUE rows.- Specified by:
executeLargeUpdate
in interfaceEngineStatement
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
JDBC 3.0 Execute 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.- Specified by:
executeUpdate
in interfaceStatement
- Parameters:
sql
- a SQL INSERT, UPDATE or DELETE statement or a SQL statement that returns nothingautoGeneratedKeys
- - 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- Returns:
- either the row count for INSERT, UPDATE or DELETE; or 0 for SQL statements that return nothing
- Throws:
SQLException
- if a database access error occurs
-
executeLargeUpdate
JDBC 4.2 Execute 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. For use with statements which may touch more than Integer.MAX_VALUE rows.- Specified by:
executeLargeUpdate
in interfaceEngineStatement
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
JDBC 3.0 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. The driver will ignore the array if the SQL statement is not an INSERT statement- Specified by:
executeUpdate
in interfaceStatement
- Parameters:
sql
- a SQL INSERT, UPDATE or DELETE statement or a SQL statement that returns nothingcolumnIndexes
- - an array of column indexes indicating the columns that should be returned from the inserted row- Returns:
- either the row count for INSERT, UPDATE or DELETE; or 0 for SQL statements that return nothing
- Throws:
SQLException
- if a database access error occurs
-
executeLargeUpdate
JDBC 4.2 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. The driver will ignore the array if the SQL statement is not an INSERT/UPDATE statement. For use with statements which may touch more than Integer.MAX_VALUE rows.- Specified by:
executeLargeUpdate
in interfaceEngineStatement
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
JDBC 3.0 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. The driver will ignore the array if the SQL statement is not an INSERT statement- Specified by:
executeUpdate
in interfaceStatement
- Parameters:
sql
- a SQL INSERT, UPDATE or DELETE statement or a SQL statement that returns nothingcolumnNames
- - an array of the names of the columns that should be returned from the inserted row- Returns:
- either the row count for INSERT, UPDATE or DELETE; or 0 for SQL statements that return nothing
- Throws:
SQLException
- if a database access error occurs
-
executeLargeUpdate
JDBC 4.2 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. The driver will ignore the array if the SQL statement is not an INSERT/UPDATE statement. For use with statements which may touch more than Integer.MAX_VALUE rows.- Specified by:
executeLargeUpdate
in interfaceEngineStatement
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
checkIfInMiddleOfBatch
- Throws:
SQLException
-
isClosed
Tell whether this statment has been closed or not.- Specified by:
isClosed
in interfaceStatement
- Returns:
true
is closed,false
otherwise.- Throws:
SQLException
- if a database access error occurs.
-
close
In many cases, it is desirable to immediately release a Statements's database and JDBC resources instead of waiting for this to happen when it is automatically closed; the close method provides this immediate release.Note: A Statement is automatically closed when it is garbage collected. When a Statement is closed its current ResultSet, if one exists, is also closed.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Throws:
SQLException
- thrown on failure.
-
finalize
Mark the statement and its single-use activation as unused. This method should be called fromEmbedPreparedStatement
's finalizer as well, even though prepared statements reuse activations, sincegetGeneratedKeys()
uses a single-use activation regardless of statement type.
Dynamic result sets (those in dynamicResults array) need not be handled here as they will be handled by the statement object that created them. In some cases results will point to a ResultSet in dynamicResults but all that will happen is that the activation will get marked as unused twice. -
closeActions
- Throws:
SQLException
-
getMaxFieldSize
The maxFieldSize limit (in bytes) is the maximum amount of data returned for any column value; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR columns. If the limit is exceeded, the excess data is silently discarded.- Specified by:
getMaxFieldSize
in interfaceStatement
- Returns:
- the current max column size limit; zero means unlimited
- Throws:
SQLException
- thrown on failure.
-
setMaxFieldSize
The maxFieldSize limit (in bytes) is set to limit the size of data that can be returned for any column value; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR fields. If the limit is exceeded, the excess data is silently discarded.- Specified by:
setMaxFieldSize
in interfaceStatement
- Parameters:
max
- the new max column size limit; zero means unlimited- Throws:
SQLException
- thrown on failure.
-
getMaxRows
The maxRows limit is the maximum number of rows that a ResultSet can contain. If the limit is exceeded, the excess rows are silently dropped.- Specified by:
getMaxRows
in interfaceStatement
- Returns:
- the current max row limit; zero means unlimited
- Throws:
SQLException
- thrown on failure.
-
getLargeMaxRows
JDBC 4.2 The maxRows limit is the maximum number of rows that a ResultSet can contain. If the limit is exceeded, the excess rows are silently dropped. For use with statements which may touch more than Integer.MAX_VALUE rows.- Specified by:
getLargeMaxRows
in interfaceEngineStatement
- Specified by:
getLargeMaxRows
in interfaceStatement
- Returns:
- the current max row limit; zero means unlimited
- Throws:
SQLException
- thrown on failure.
-
setMaxRows
The maxRows limit is set to limit the number of rows that any ResultSet can contain. If the limit is exceeded, the excess rows are silently dropped.- Specified by:
setMaxRows
in interfaceStatement
- Parameters:
max
- the new max rows limit; zero means unlimited- Throws:
SQLException
- thrown on failure.
-
setLargeMaxRows
The maxRows limit is set to limit the number of rows that any ResultSet can contain. If the limit is exceeded, the excess rows are silently dropped.- Specified by:
setLargeMaxRows
in interfaceEngineStatement
- Specified by:
setLargeMaxRows
in interfaceStatement
- Parameters:
max
- the new max rows limit; zero means unlimited- Throws:
SQLException
- thrown on failure.
-
setEscapeProcessing
If escape scanning is on (the default) the driver will do escape substitution before sending the SQL to the database.- Specified by:
setEscapeProcessing
in interfaceStatement
- Parameters:
enable
- true to enable; false to disable- Throws:
SQLException
- thrown on failure.
-
getQueryTimeout
The queryTimeout limit is the number of seconds the driver will wait for a Statement to execute. If the limit is exceeded a SQLException is thrown.- Specified by:
getQueryTimeout
in interfaceStatement
- Returns:
- the current query timeout limit in seconds; zero means unlimited
- Throws:
SQLException
- thrown on failure.
-
setQueryTimeout
The queryTimeout limit is the number of seconds the driver will wait for a Statement to execute. If the limit is exceeded a SQLException is thrown.- Specified by:
setQueryTimeout
in interfaceStatement
- Parameters:
seconds
- the new query timeout limit in seconds; zero means unlimited- Throws:
SQLException
- thrown on failure.
-
cancel
Cancel can be used by one thread to cancel a statement that is being executed by another thread.- Specified by:
cancel
in interfaceStatement
- Throws:
SQLException
- thrown on failure.
-
getWarnings
The first warning reported by calls on this Statement is returned. A Statment's execute methods clear its SQLWarning chain. Subsequent Statement warnings will be chained to this SQLWarning.The warning chain is automatically cleared each time a statement is (re)executed.
Note: If you are processing a ResultSet then any warnings associated with ResultSet reads will be chained on the ResultSet object.
- Specified by:
getWarnings
in interfaceStatement
- Returns:
- the first SQLWarning or null
- Throws:
SQLException
- thrown on failure.
-
clearWarnings
After this call getWarnings returns null until a new warning is reported for this Statement.- Specified by:
clearWarnings
in interfaceStatement
- Throws:
SQLException
- thrown on failure.
-
setCursorName
setCursorName defines the SQL cursor name that will be used by subsequent Statement execute methods. This name can then be used in SQL positioned update/delete statements to identify the current row in the ResultSet generated by this statement. If the database doesn't support positioned update/delete, this method is a noop.Note: By definition, positioned update/delete execution must be done by a different Statement than the one which generated the ResultSet being used for positioning. Also, cursor names must be unique within a Connection.
- Specified by:
setCursorName
in interfaceStatement
- Parameters:
name
- the new cursor name.- Throws:
SQLException
-
execute
Execute a SQL statement that may return multiple results. Under some (uncommon) situations a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this, unless you're executing a stored procedure that you know may return multiple results, or unless you're dynamically executing an unknown SQL string. The "execute", "getMoreResults", "getResultSet" and "getUpdateCount" methods let you navigate through multiple results. The "execute" method executes a SQL statement and indicates the form of the first result. You can then use getResultSet or getUpdateCount to retrieve the result, and getMoreResults to move to any subsequent result(s).- Specified by:
execute
in interfaceStatement
- Parameters:
sql
- any SQL statement- Returns:
- true if the first result is a ResultSet; false if it is an integer
- Throws:
SQLException
- thrown on failure- See Also:
-
execute
private boolean execute(String sql, boolean executeQuery, boolean executeUpdate, int autoGeneratedKeys, int[] columnIndexes, String[] columnNames) throws SQLException Execute a SQL statement that may return multiple results. Under some (uncommon) situations a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this, unless you're executing a stored procedure that you know may return multiple results, or unless you're dynamically executing an unknown SQL string. The "execute", "getMoreResults", "getResultSet" and "getUpdateCount" methods let you navigate through multiple results. The "execute" method executes a SQL statement and indicates the form of the first result. You can then use getResultSet or getUpdateCount to retrieve the result, and getMoreResults to move to any subsequent result(s).- Parameters:
sql
- any SQL statementexecuteQuery
- caller is executeQuery()executeUpdate
- caller is executeUpdate()autoGeneratedKeys
-columnIndexes
-columnNames
-- Returns:
- true if the first result is a ResultSet; false if it is an integer
- Throws:
SQLException
- thrown on failure- See Also:
-
execute
JDBC 3.0 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. The driver will ignore this signal if the SQL statement is not an INSERT/UPDATE statement.- Specified by:
execute
in interfaceStatement
- Parameters:
sql
- any SQL statementautoGeneratedKeys
- - 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- Returns:
- rue if the first result is a ResultSet object; false if it is an update count or there are no results
- Throws:
SQLException
- if a database access error occurs
-
execute
JDBC 3.0 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. This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the given SQL statement is not an INSERT/UPDATE statement.- Specified by:
execute
in interfaceStatement
- Parameters:
sql
- any SQL statementcolumnIndexes
- - an array of the indexes of the columns in the inserted/updated row that should be made available for retrieval by a call to the method getGeneratedKeys- Returns:
- rue if the first result is a ResultSet object; false if it is an update count or there are no results
- Throws:
SQLException
- if a database access error occurs
-
execute
JDBC 3.0 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. This array contains the names of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the given SQL statement is not an INSERT/UPDATE statement.- Specified by:
execute
in interfaceStatement
- Parameters:
sql
- any SQL statementcolumnNames
- - an array of the names of the columns in the inserted/updated row that should be made available for retrieval by a call to the method getGeneratedKeys- Returns:
- rue if the first result is a ResultSet object; false if it is an update count or there are no results
- Throws:
SQLException
- if a database access error occurs
-
getResultSet
getResultSet returns the current result as a ResultSet. It should only be called once per result.- Specified by:
getResultSet
in interfaceStatement
- Returns:
- the current result as a ResultSet; null if the result is an update count or there are no more results or the statement was closed.
- Throws:
SQLException
- See Also:
-
getUpdateCount
getUpdateCount returns the current result as an update count; if the result is a ResultSet or there are no more results -1 is returned. It should only be called once per result.The only way to tell for sure that the result is an update count is to first test to see if it is a ResultSet. If it is not a ResultSet it is either an update count or there are no more results.
- Specified by:
getUpdateCount
in interfaceStatement
- Returns:
- the current result as an update count; -1 if it is a ResultSet or there are no more results
- Throws:
SQLException
- See Also:
-
getLargeUpdateCount
JDBC 4.2 getLargeUpdateCount returns the current result as an update count; if the result is a ResultSet or there are no more results -1 is returned. It should only be called once per result. For use with statements which may touch more than Integer.MAX_VALUE rows.- Specified by:
getLargeUpdateCount
in interfaceEngineStatement
- Specified by:
getLargeUpdateCount
in interfaceStatement
- Throws:
SQLException
-
getMoreResults
getMoreResults moves to a Statement's next result. It returns true if this result is a ResultSet. getMoreResults also implicitly closes any current ResultSet obtained with getResultSet. There are no more results when (!getMoreResults() && (getUpdateCount() == -1)- Specified by:
getMoreResults
in interfaceStatement
- Returns:
- true if the next result is a ResultSet; false if it is an update count or there are no more results
- Throws:
SQLException
- thrown on failure.- See Also:
-
getResultSetType
JDBC 2.0 Determine the result set type.- Specified by:
getResultSetType
in interfaceStatement
- Throws:
SQLException
- Feature not implemented for now.
-
setFetchDirection
JDBC 2.0 Give a hint as to the direction in which the rows in a result set will be processed. The hint applies only to result sets created using this Statement object. The default value is ResultSet.FETCH_FORWARD.- Specified by:
setFetchDirection
in interfaceStatement
- Parameters:
direction
- the initial direction for processing rows- Throws:
SQLException
- if a database-access error occurs or direction is not one of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or ResultSet.FETCH_UNKNOWN
-
getFetchDirection
JDBC 2.0 Determine the fetch direction.- Specified by:
getFetchDirection
in interfaceStatement
- Returns:
- the default fetch direction
- Throws:
SQLException
- if a database-access error occurs
-
setFetchSize
JDBC 2.0 Give the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. The number of rows specified only affects result sets created using this statement. If the value specified is zero, then the hint is ignored. The default value is zero.- Specified by:
setFetchSize
in interfaceStatement
- Parameters:
rows
- the number of rows to fetch- Throws:
SQLException
- if a database-access error occurs, or the condition 0 <= rows <= this.getMaxRows() is not satisfied.
-
getFetchSize
JDBC 2.0 Determine the default fetch size.- Specified by:
getFetchSize
in interfaceStatement
- Throws:
SQLException
- if a database-access error occurs
-
getResultSetConcurrency
JDBC 2.0 Determine the result set concurrency.- Specified by:
getResultSetConcurrency
in interfaceStatement
- Throws:
SQLException
- Feature not implemented for now.
-
getResultSetHoldability
JDBC 3.0 Retrieves the result set holdability for ResultSet objects generated by this Statement object.- Specified by:
getResultSetHoldability
in interfaceStatement
- Returns:
- either ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
- Throws:
SQLException
- Feature not implemented for now.
-
addBatch
JDBC 2.0 Adds a SQL command to the current batch of commmands for the statement. This method is optional.- Specified by:
addBatch
in interfaceStatement
- Parameters:
sql
- typically this is a static SQL INSERT or UPDATE statement- Throws:
SQLException
- if a database-access error occurs, or the driver does not support batch statements
-
clearBatch
JDBC 2.0 Make the set of commands in the current batch empty. This method is optional.- Specified by:
clearBatch
in interfaceStatement
- Throws:
SQLException
- if a database-access error occurs, or the driver does not support batch statements
-
executeBatch
JDBC 2.0 Submit a batch of commands to the database for execution. This method is optional. Moving jdbc2.0 batch related code in this class because callableStatement in jdbc 20 needs this code too and it doesn't derive from prepared statement in jdbc 20 in our implementation. BatchUpdateException is the only new class from jdbc 20 which is being referenced here and in order to avoid any jdk11x problems, using reflection code to make an instance of that class.- Specified by:
executeBatch
in interfaceStatement
- Returns:
- an array of update counts containing one element for each command in the batch. The array is ordered according to the order in which commands were inserted into the batch
- Throws:
SQLException
- if a database-access error occurs, or the driver does not support batch statements
-
executeLargeBatch
JDBC 4.2 Submit a batch of commands to the database for execution. This method is optional. For use with statements which may touch more than Integer.MAX_VALUE rows.- Specified by:
executeLargeBatch
in interfaceEngineStatement
- Specified by:
executeLargeBatch
in interfaceStatement
- Throws:
SQLException
-
executeBatchElement
Execute a single element of the batch. Overridden by EmbedPreparedStatement- Throws:
SQLException
StandardException
-
getConnection
JDBC 2.0 Return the Connection that produced the Statement.- Specified by:
getConnection
in interfaceStatement
- Throws:
SQLException
- Exception if it cannot find the connection associated to this statement.
-
getMoreResults
JDBC 3.0 Moves to this Statement obect'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- Specified by:
getMoreResults
in interfaceStatement
- Parameters:
current
- - one of the following Statement constants indicating what should happen to current ResultSet objects obtained using the method getResultSetCLOSE_CURRENT_RESULT, KEEP_CURRENT_RESULT, or CLOSE_ALL_RESULTS- Returns:
- true if the next result is a ResultSet; false if it is an update count or there are no more results
- Throws:
SQLException
- thrown on failure.- See Also:
-
getGeneratedKeys
JDBC 3.0 Retrieves any auto-generated keys created as a result of executing this Statement object. If this Statement is a non-insert statement, a null ResultSet object is returned.- Specified by:
getGeneratedKeys
in interfaceStatement
- Returns:
- a ResultSet object containing the auto-generated key(s) generated by the execution of this Statement object
- Throws:
SQLException
- if a database access error occurs
-
executeStatement
boolean executeStatement(Activation a, boolean executeQuery, boolean executeUpdate) throws SQLException Execute the current statement.- Throws:
SQLException
- thrown on failure.
-
addWarning
Add a SQLWarning to this Statement object. If the Statement already has a SQLWarning then it is added to the end of the chain.- See Also:
-
getSQLText
-
getParameterValueSet
-
checkStatus
Throw an exception if this Statement has been closed explictly or it has noticed it has been closed implicitly. JDBC specifications require nearly all methods throw a SQLException if the Statement has been closed, thus most methods call this method or checkExecStatus first.- Throws:
SQLException
- Thrown if the statement is marked as closed.- See Also:
-
checkExecStatus
A heavier weight version of checkStatus() that ensures the application's Connection object is still open. This is to stop errors or unexpected behaviour when a [Prepared]Statement object is used after the application has been closed. In particular to ensure that a Statement obtained from a PooledConnection cannot be used after the application has closed its connection (as the underlying Connection is still active). To avoid this heavier weight check on every method of [Prepared]Statement it is only used on those methods that would end up using the database's connection to read or modify data. E.g. execute*(), but not setXXX, etc.
If this Statement's Connection is closed an exception will be thrown and the active field will be set to false, completely marking the Statement as closed.
If the Statement is not currently connected to an active transaction, i.e. a suspended global transaction, then this method will throw a SQLException but the Statement will remain open. The Statement is open but unable to process any new requests until its global transaction is resumed.
Upon return from the method, with or without a SQLException the field active will correctly represent the open state of the Statement.- Throws:
SQLException
- Thrown if the statement is marked as closed or the Statement's transaction is suspended.- See Also:
-
clearResultSets
Close and clear all result sets associated with this statement from the last execution.- Throws:
SQLException
-
clearResultSetsMinion
- Throws:
SQLException
-
checkRequiresCallableStatement
Check to see if a statement requires to be executed via a callable statement.- Throws:
SQLException
-
transferBatch
Transfer my batch of Statements to a newly created Statement.- Throws:
SQLException
-
setApplicationStatement
Set the application statement for this Statement. -
processDynamicResults
private int processDynamicResults(ResultSet[][] holder, int maxDynamicResultSets) throws SQLException Go through a holder of dynamic result sets, remove those that should not be returned, and sort the result sets according to their creation.- Parameters:
holder
- a holder of dynamic result setsmaxDynamicResultSets
- the maximum number of result sets to be returned- Returns:
- the actual number of result sets
- Throws:
SQLException
- if an error occurs
-
processDynamicResult
static EmbedResultSet processDynamicResult(EmbedConnection conn, ResultSet resultSet, EmbedStatement callStatement) Process a ResultSet created in a Java procedure as a dynamic result. To be a valid dynamic result the ResultSet must be:- From a Derby system
- From a nested connection of connection passed in or from the connection itself.
- Open
- Parameters:
conn
- Connection ResultSet needs to belong toresultSet
- ResultSet to be testedcallStatement
- Statement that executed the CALL, null if- Returns:
- The result set cast down to EmbedResultSet, null if not a valid dynamic result.
-
resultSetClosing
Callback on the statement when one of its result sets is closed. This allows the statement to control when it completes and hence when it commits in auto commit mode. Must have connection synchronization and setupContextStack(), this is required for the call to commitIfNeeded().- Throws:
SQLException
-
getExecuteHoldable
Get the execute time holdability for the Statement. When in a global transaction holdabilty defaults to false.- Throws:
SQLException
- Error from getResultSetHoldability.
-
isPoolable
Returns the value of the EmbedStatement's poolable hint, indicating whether pooling is requested.- Specified by:
isPoolable
in interfaceStatement
- Returns:
- The value of the poolable hint.
- Throws:
SQLException
- if the Statement has been closed.
-
setPoolable
Requests that an EmbedStatement be pooled or not.- Specified by:
setPoolable
in interfaceStatement
- Parameters:
poolable
- requests that the EmbedStatement be pooled if true and not be pooled if false.- Throws:
SQLException
- if the EmbedStatement has been closed.
-
isWrapperFor
Returns false unlessinterfaces
is implemented.- Specified by:
isWrapperFor
in interfaceWrapper
- Parameters:
interfaces
- a Class defining an interface.- Returns:
- true if this implements the interface or directly or indirectly wraps an object that does.
- Throws:
SQLException
- if an error occurs while determining whether this is a wrapper for an object with the given interface.
-
unwrap
Returnsthis
if this class implements the interface.- Specified by:
unwrap
in interfaceWrapper
- Parameters:
interfaces
- a Class defining an interface- Returns:
- an object that implements the interface
- Throws:
SQLException
- if no object if found that implements the interface
-
closeOnCompletion
- Specified by:
closeOnCompletion
in interfaceEngineStatement
- Specified by:
closeOnCompletion
in interfaceStatement
- Throws:
SQLException
-
isCloseOnCompletion
- Specified by:
isCloseOnCompletion
in interfaceEngineStatement
- Specified by:
isCloseOnCompletion
in interfaceStatement
- Throws:
SQLException
-
closeMeOnCompletion
void closeMeOnCompletion() -
isOpen
- Throws:
SQLException
-