Package org.apache.derby.client.am
Class ClientStatement
java.lang.Object
org.apache.derby.client.am.ClientStatement
- All Implemented Interfaces:
AutoCloseable
,Statement
,Wrapper
,StatementCallbackInterface
,UnitOfWorkListener
- Direct Known Subclasses:
ClientPreparedStatement
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Agent
(package private) int
private boolean
private boolean
(package private) ClientConnection
(package private) String
protected boolean
(package private) static final int
(package private) static final int
(package private) static final int
(package private) int
private static long
For use in debugging setLargeMaxRows() method added by JDBC 4.2(package private) int
(package private) int[]
(package private) String[]
(package private) ClientResultSet
private int
private static final int
private static final int
(package private) boolean
(package private) static final int
(package private) boolean
(package private) static final int
(package private) static final int
protected boolean
(package private) boolean
(package private) static final int
(package private) static final int
(package private) static final int
private MaterialStatement
(package private) int
(package private) long
(package private) boolean
private static final int
State constants used by the FSM inside getStatementToken.private Statement
The owner of this statement, if any.(package private) ClientPreparedStatement
(package private) ClientResultSet
int
(package private) int
(package private) ClientResultSet[]
(package private) ColumnMetaData
int
private Section
private Section
This variable keeps track of a Section dediacted to writeSpecialRegister.(package private) Cursor
protected int
(package private) int
(package private) int
protected static final String
(package private) long
private SqlWarning
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
ConstructorsModifierConstructorDescriptionprivate
ClientStatement
(Agent agent, ClientConnection connection) ClientStatement
(Agent agent, ClientConnection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
(package private) String
void
cancel()
(package private) void
(package private) final void
checkForAppropriateSqlMode
(int executeType, int sqlMode) (package private) final void
protected void
private void
protected final void
checkForStoredProcResultSetCount
(int executeType) Checks that a stored procedure returns the correct number of result sets given its execute type.private void
checkResultSetCount
(int executeType) Checks that the number of result sets returned by the statement is consistent with the executed type.void
void
(package private) final void
void
close()
private void
closeEverythingExceptResultSets
(boolean removeListener) Close all resources except for ResultSets.(package private) void
void
(package private) void
closeX()
An untraced version ofclose
.void
completeExecute
(Sqlca sqlca) void
completeExecuteCall
(Sqlca sqlca, Cursor singletonParams) void
completeExecuteCall
(Sqlca sqlca, Cursor singletonParams, ClientResultSet[] resultSets) void
completeExecuteCallOpenQuery
(Sqlca sqlca, ClientResultSet resultSet, ColumnMetaData resultSetMetaData, Section generatedSection) void
completeExecuteImmediate
(Sqlca sqlca) void
completeExecuteSetStatement
(Sqlca sqlca) void
completeLocalCommit
(Iterator listenerIterator) void
completeLocalRollback
(Iterator listenerIterator) void
completeOpenQuery
(Sqlca sqlca, ClientResultSet resultSet) void
completePrepare
(Sqlca sqlca) void
completePrepareDescribeOutput
(ColumnMetaData resultSetMetaData, Sqlca sqlca) int
completeSqlca
(Sqlca sqlca) (package private) String
boolean
boolean
boolean
boolean
int[]
private long[]
long[]
long
executeLargeUpdate
(String sql) long
executeLargeUpdate
(String sql, int autoGeneratedKeys) long
executeLargeUpdate
(String sql, int[] columnIndexes) long
executeLargeUpdate
(String sql, String[] columnNames) executeQuery
(String sql) private ClientResultSet
executeQueryX
(String sql) int
executeUpdate
(String sql) int
executeUpdate
(String sql, int autoGeneratedKeys) int
executeUpdate
(String sql, int[] columnIndexes) int
executeUpdate
(String sql, String[] columnNames) private long
executeUpdateX
(String sql) (package private) boolean
(package private) String[]
protected void
finalize()
private void
private void
private void
private void
private void
flowExecute
(int executeType, String sql) private void
flowExecuteBatch
(long[] updateCounts) int
int
protected String
Returns the name of the java.sql interface implemented by this class.long
long
int
int
boolean
boolean
getMoreResults
(int current) private boolean
getMoreResultsX
(int current) (package private) final Statement
getOwner()
Returns the owner of this statement, if any.int
int
int
int
Provides public access for section_.protected SqlWarning
private String
getStatementToken
(String sql) Step past any initial non-significant characters and comments to find first significant SQL token so we can classify statement.int
protected void
private void
private void
private void
initStatement
(int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes) private void
initStatement
(Agent agent, ClientConnection connection) boolean
isClosed()
Tell whether the statement has been closed or not.boolean
private String
Minion of getStatementToken.private boolean
boolean
Returns the value of the poolable hint, indicating whether pooling is requested.boolean
boolean
isWrapperFor
(Class<?> iface) Returns false unlessiface
is implementedvoid
private void
private void
Mark all ResultSets associated with this statement as auto-committed.(package private) void
This method cleans up client-side resources held by this Statement.(package private) void
markClosed
(boolean removeListener) This method cleans up client-side resources held by this Statement.private void
private void
(package private) final void
markResultSetsClosed
(boolean removeListener) Mark all ResultSets associated with this statement as closed.(package private) void
(package private) void
private void
parseUpdateSql
(String firstToken) protected static ClientPreparedStatement
(package private) final void
readClose
(boolean allowAutoCommits) (package private) final void
readCloseResultSets
(boolean allowAutoCommits) private void
readCloseResultSets
(int number, boolean allowAutoCommits) (package private) void
private void
private void
(package private) void
(package private) void
(package private) void
(package private) void
protected void
void
reset
(boolean fullReset) (package private) void
(package private) void
Resets the statement for reuse in a statement pool.(package private) void
private void
(package private) void
resetStatement
(Agent agent, ClientConnection connection) void
resetStatement
(Agent agent, ClientConnection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes) private void
Resets attributes that can be modified by the user through theStatement
interface to default values.(package private) void
resultSetCommitting
(ClientResultSet closingRS) Convenience method for resultSetCommitting(ClientResultSet, boolean)(package private) boolean
resultSetCommitting
(ClientResultSet closingRS, boolean writeChain) Method that checks to see if any other ResultSets are open.void
setCursorName
(String name) void
setEscapeProcessing
(boolean enable) void
setFetchDirection
(int direction) static void
setFetchedRowBase
(long newBase) Debug method used to test the setLargeMaxRows() method added by JDBC 4.2.void
setFetchSize
(int rows) void
setLargeMaxRows
(long maxRows) void
setMaterialStatement
(MaterialStatement materialStatement) void
setMaxFieldSize
(int max) void
setMaxRows
(int maxRows) protected final void
Designates the owner of this statement, typically a logical statement.void
setPoolable
(boolean poolable) Requests that a Statement be pooled or not.void
setQueryTimeout
(int seconds) protected void
Assigns a new value (even null) to section_.protected void
void
setUpdateCount
(long updateCount) protected String
substituteClientCursorNameWithServerCursorName
(String sql, Section section) <T> T
Returnsthis
if this class implements the specified interface.private boolean
willTickleServer
(int number, boolean allowAutoCommits) (package private) final void
writeClose
(boolean allowAutoCommits) (package private) final boolean
writeCloseResultSets
(boolean allowAutoCommits) The connection close processing passes allowAutoCommits=false because if we drove an auto-commits after each statement close, then when we issue close requests on non-held cursors the server would complain that the non-held cursor was already closed from the previous statement's auto-commit.private boolean
writeCloseResultSets
(int number, boolean allowAutoCommits) (package private) void
writeExecuteCall
(boolean outputExpected, String procedureName, Section section, int fetchSize, boolean suppressResultSets, int resultSetType, ColumnMetaData parameterMetaData, Object[] inputs) private Section
writeExecuteCall
(String sql, boolean isBatch) private void
writeExecuteImmediate
(String sql, Section section) (package private) void
writeOpenQuery
(Section section, int fetchSize, int resultSetType) (package private) void
writePrepare
(String sql, Section section) (package private) void
writePrepareDescribeOutput
(String sql, Section section) (package private) void
writeSetSpecialRegister
(ArrayList sqlsttList) 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
-
fetchedRowBase
private static long fetchedRowBaseFor use in debugging setLargeMaxRows() method added by JDBC 4.2 -
materialStatement_
-
connection_
ClientConnection connection_ -
section_
-
agent_
Agent agent_ -
owner
The owner of this statement, if any. -
resultSet_
ClientResultSet resultSet_ -
updateCount_
long updateCount_ -
executeQueryMethod__
static final int executeQueryMethod__- See Also:
-
executeUpdateMethod__
static final int executeUpdateMethod__- See Also:
-
executeMethod__
static final int executeMethod__- See Also:
-
sqlMode_
protected int sqlMode_ -
isQuery__
static final int isQuery__- See Also:
-
isCall__
static final int isCall__- See Also:
-
isUpdate__
static final int isUpdate__- See Also:
-
sqlUpdateMode_
int sqlUpdateMode_ -
isInsertSql__
static final int isInsertSql__- See Also:
-
isDeleteSql__
static final int isDeleteSql__- See Also:
-
isUpdateSql__
static final int isUpdateSql__- See Also:
-
resultSetMetaData_
ColumnMetaData resultSetMetaData_ -
cachedCursor_
-
cachedSingletonRowData_
-
isPreparedStatement_
boolean isPreparedStatement_ -
cursorName_
String cursorName_ -
openOnClient_
boolean openOnClient_ -
indexOfCurrentResultSet_
private int indexOfCurrentResultSet_ -
resultSetList_
ClientResultSet[] resultSetList_ -
TIMEOUT_STATEMENT
- See Also:
-
timeoutArrayList
-
doWriteTimeout
protected boolean doWriteTimeout -
timeout_
int timeout_ -
maxRows_
long maxRows_ -
maxFieldSize_
int maxFieldSize_ -
isAutoCommittableStatement_
boolean isAutoCommittableStatement_ -
isCatalogQuery_
boolean isCatalogQuery_ -
batch_
-
resultSetType_
public int resultSetType_ -
resultSetConcurrency_
public int resultSetConcurrency_ -
resultSetHoldability_
int resultSetHoldability_ -
fetchSize_
int fetchSize_ -
fetchDirection_
int fetchDirection_ -
singletonRowData_
Cursor singletonRowData_ -
cursorAttributesToSendOnPrepare_
-
preparedStatementForAutoGeneratedKeys_
ClientPreparedStatement preparedStatementForAutoGeneratedKeys_ -
generatedKeysResultSet_
ClientResultSet generatedKeysResultSet_ -
generatedKeysColumnNames_
String[] generatedKeysColumnNames_ -
generatedKeysColumnIndexes_
int[] generatedKeysColumnIndexes_ -
autoGeneratedKeys_
int autoGeneratedKeys_ -
warnings_
-
isPoolable
protected boolean isPoolable -
closeOnCompletion_
private boolean closeOnCompletion_ -
closingResultSets_
private boolean closingResultSets_ -
setSpecialRegisterSection_
This variable keeps track of a Section dediacted to writeSpecialRegister. It gets initialized the first time a Section is needed, and freed when the Statement is closed. -
OUTSIDE
private static final int OUTSIDEState constants used by the FSM inside getStatementToken.- See Also:
-
INSIDE_SIMPLECOMMENT
private static final int INSIDE_SIMPLECOMMENT- See Also:
-
INSIDE_BRACKETED_COMMENT
private static final int INSIDE_BRACKETED_COMMENT- See Also:
-
-
Constructor Details
-
ClientStatement
private ClientStatement() -
ClientStatement
- Throws:
SqlException
-
ClientStatement
public ClientStatement(Agent agent, ClientConnection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes) throws SqlException - Throws:
SqlException
-
-
Method Details
-
setFetchedRowBase
public static void setFetchedRowBase(long newBase) Debug method used to test the setLargeMaxRows() method added by JDBC 4.2. This method is a NOP on a production (insane) build of Derby. -
getMaterialStatement
- Returns:
- the materialStatement
-
setMaterialStatement
- Parameters:
materialStatement
- the materialStatement to set
-
resetStatement
private void resetStatement() -
initStatement
private void initStatement() -
initResetStatement
private void initResetStatement() -
initResetPreparedStatement
protected void initResetPreparedStatement() -
resetUserControllableAttributes
private void resetUserControllableAttributes()Resets attributes that can be modified by the user through theStatement
interface to default values. -
reset
- Throws:
SqlException
-
resetForReuse
Resets the statement for reuse in a statement pool.Intended to be used only by prepared or callable statements, as
Statement
objects aren't pooled.The following actions are taken:
- Batches are cleared.
- Warnings are cleared.
- Open result set are closed on the client and the server.
- Cached cursor names are cleared.
- Statement for fetching auto-generated keys is closed.
- Special registers are reset.
- User controllable attributes are reset to defaults, for instance query timeout and max rows to fetch.
- Throws:
SqlException
- if resetting the statement fails
-
resetStatement
- Throws:
SqlException
-
initStatement
-
resetStatement
public void resetStatement(Agent agent, ClientConnection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes) throws SqlException - Throws:
SqlException
-
initStatement
private void initStatement(int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes) throws SqlException - Throws:
SqlException
-
finalize
-
getSqlWarnings
-
executeQuery
- Specified by:
executeQuery
in interfaceStatement
- Throws:
SQLException
-
executeQueryX
- Throws:
SqlException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdateX
- Throws:
SqlException
-
isWrapperFor
Returns false unlessiface
is implemented- Specified by:
isWrapperFor
in interfaceWrapper
- Parameters:
iface
- 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 specified interface.- Specified by:
unwrap
in interfaceWrapper
- Parameters:
iface
- a class defining an interface- Returns:
- an object that implements the interface
- Throws:
SQLException
- if no object is found that implements the interface
-
isClosed
Tell whether the statement has been closed or not.- Specified by:
isClosed
in interfaceStatement
- Returns:
true
if closed,false
otherwise.- Throws:
SQLException
- if a database access error occurs (according to spec). Never thrown by this implementation.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Throws:
SQLException
-
closeX
An untraced version ofclose
. This method cleans up client-side resources and also sends commands to network server to perform clean up. This should not be called in the finalizer. Difference betweenfinalize
andclose
is that close method does these things additionally (Changes done as part of DERBY-210): 1) Sends commands to the server to close the result sets. 2) Sends commands to the server to close the result sets of the generated keys query. 3) Sends a commit if autocommit is on and it is appropriate. 4) Explicitly removes the statement from connection_.openStatements_ and CommitAndRollbackListeners_ by passing true to markClosed. We may need to do 1) in finalizer too. This is being tracked in DERBY-1021- Throws:
SqlException
-
isPoolable
Returns the value of the 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 a Statement be pooled or not.- Specified by:
setPoolable
in interfaceStatement
- Parameters:
poolable
- requests that the Statement be pooled if true and not be pooled if false.- Throws:
SQLException
- if the Statement has been closed.
-
getMaxFieldSize
- Specified by:
getMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
setMaxFieldSize
- Specified by:
setMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
getMaxRows
- Specified by:
getMaxRows
in interfaceStatement
- Throws:
SQLException
-
getLargeMaxRows
- Specified by:
getLargeMaxRows
in interfaceStatement
- Throws:
SQLException
-
setMaxRows
- Specified by:
setMaxRows
in interfaceStatement
- Throws:
SQLException
-
setLargeMaxRows
- Specified by:
setLargeMaxRows
in interfaceStatement
- Throws:
SQLException
-
setEscapeProcessing
- Specified by:
setEscapeProcessing
in interfaceStatement
- Throws:
SQLException
-
getQueryTimeout
- Specified by:
getQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
setQueryTimeout
- Specified by:
setQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
cancel
- Specified by:
cancel
in interfaceStatement
- Throws:
SQLException
-
getWarnings
- Specified by:
getWarnings
in interfaceStatement
- Throws:
SQLException
-
clearWarnings
- Specified by:
clearWarnings
in interfaceStatement
- Throws:
SQLException
-
clearWarningsX
final void clearWarningsX() -
setCursorName
- Specified by:
setCursorName
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
executeX
- Throws:
SqlException
-
getResultSet
- Specified by:
getResultSet
in interfaceStatement
- Throws:
SQLException
-
getUpdateCount
- Specified by:
getUpdateCount
in interfaceStatement
- Throws:
SQLException
-
getLargeUpdateCount
- Specified by:
getLargeUpdateCount
in interfaceStatement
- Throws:
SQLException
-
getMoreResults
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
setFetchDirection
- Specified by:
setFetchDirection
in interfaceStatement
- Throws:
SQLException
-
getFetchDirection
- Specified by:
getFetchDirection
in interfaceStatement
- Throws:
SQLException
-
setFetchSize
- Specified by:
setFetchSize
in interfaceStatement
- Throws:
SQLException
-
getFetchSize
- Specified by:
getFetchSize
in interfaceStatement
- Throws:
SQLException
-
getResultSetConcurrency
- Specified by:
getResultSetConcurrency
in interfaceStatement
- Throws:
SQLException
-
getResultSetType
- Specified by:
getResultSetType
in interfaceStatement
- Throws:
SQLException
-
addBatch
- Specified by:
addBatch
in interfaceStatement
- Throws:
SQLException
-
clearBatch
- Specified by:
clearBatch
in interfaceStatement
- Throws:
SQLException
-
executeBatch
- Specified by:
executeBatch
in interfaceStatement
- Throws:
SQLException
-
executeLargeBatch
- Specified by:
executeLargeBatch
in interfaceStatement
- Throws:
SQLException
-
executeBatchX
- Throws:
SqlException
BatchUpdateException
-
getConnection
- Specified by:
getConnection
in interfaceStatement
- Throws:
SQLException
-
getMoreResults
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
getMoreResultsX
- Throws:
SqlException
-
getGeneratedKeys
- Specified by:
getGeneratedKeys
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
getResultSetHoldability
- Specified by:
getResultSetHoldability
in interfaceStatement
- Throws:
SQLException
-
writeSetSpecialRegister
- Throws:
SqlException
-
readSetSpecialRegister
- Throws:
SqlException
-
writeExecuteImmediate
- Throws:
SqlException
-
readExecuteImmediate
- Throws:
SqlException
-
completeExecuteImmediate
- Specified by:
completeExecuteImmediate
in interfaceStatementCallbackInterface
-
readExecuteImmediateForBatch
- Throws:
SqlException
-
writePrepareDescribeOutput
- Throws:
SqlException
-
readPrepareDescribeOutput
- Throws:
SqlException
-
completePrepareDescribeOutput
- Specified by:
completePrepareDescribeOutput
in interfaceStatementCallbackInterface
-
writePrepare
- Throws:
SqlException
-
readPrepare
- Throws:
SqlException
-
completePrepare
- Specified by:
completePrepare
in interfaceStatementCallbackInterface
-
writeOpenQuery
- Throws:
SqlException
-
readOpenQuery
- Throws:
SqlException
-
completeOpenQuery
- Specified by:
completeOpenQuery
in interfaceStatementCallbackInterface
-
completeExecuteCallOpenQuery
public void completeExecuteCallOpenQuery(Sqlca sqlca, ClientResultSet resultSet, ColumnMetaData resultSetMetaData, Section generatedSection) - Specified by:
completeExecuteCallOpenQuery
in interfaceStatementCallbackInterface
-
writeExecuteCall
void writeExecuteCall(boolean outputExpected, String procedureName, Section section, int fetchSize, boolean suppressResultSets, int resultSetType, ColumnMetaData parameterMetaData, Object[] inputs) throws SqlException - Throws:
SqlException
-
readExecuteCall
- Throws:
SqlException
-
completeExecuteCall
- Specified by:
completeExecuteCall
in interfaceStatementCallbackInterface
-
completeExecuteCall
- Specified by:
completeExecuteCall
in interfaceStatementCallbackInterface
-
completeExecute
- Specified by:
completeExecute
in interfaceStatementCallbackInterface
-
setUpdateCount
public void setUpdateCount(long updateCount) -
setOwner
Designates the owner of this statement, typically a logical statement.- Parameters:
owner
- the owning statement, if any
-
getOwner
Returns the owner of this statement, if any.- Returns:
- The designated owner of this statement, or
null
if none.
-
willTickleServer
- Throws:
SqlException
-
flowClose
- Throws:
SqlException
-
flowCloseOutsideUOW
- Throws:
SqlException
-
writeClose
- Throws:
SqlException
-
readClose
- Throws:
SqlException
-
writeCloseResultSets
The connection close processing passes allowAutoCommits=false because if we drove an auto-commits after each statement close, then when we issue close requests on non-held cursors the server would complain that the non-held cursor was already closed from the previous statement's auto-commit. So the solution is to never auto-commit statements during connection close processing. Here's the operative explanation: Given a sequence of open statements S1, S2, .... a logic problem is occurring after S1 close-query drives an auto-commit, and S2 close-query is driven against a non-held cursor. The first auto-commit driven by S1 triggers a callback that closes S2's non-held cursor, and so the subsequent S2 close-query request generates an error from the server saying that the cursor is already closed. This is fixed by passing a flag to our statement close processing that prevents driving additional auto-commits after each statement close. Connection close drives its own final auto-commit.- Parameters:
allowAutoCommits
-- Throws:
SqlException
-
writeCloseResultSets
- Throws:
SqlException
-
readCloseResultSets
- Throws:
SqlException
-
readCloseResultSets
- Throws:
SqlException
-
flowCloseRetrievedResultSets
- Throws:
SqlException
-
flowCloseRetrievedResultSetsOutsideUOW
- Throws:
SqlException
-
completeSqlca
- Specified by:
completeSqlca
in interfaceStatementCallbackInterface
-
completeExecuteSetStatement
- Specified by:
completeExecuteSetStatement
in interfaceStatementCallbackInterface
-
markClosed
void markClosed()This method cleans up client-side resources held by this Statement. The Statement will not be removed from the open statements list and PreparedStatement will also not be removed from the commit and rollback listeners list inorg.apache.derby.client.am.Connection
. This method is called from: 1. finalize() - For the finalizer to be called, the Statement should not have any references and so it should have been already removed from the lists. 2.org.apache.derby.client.am.Connection#markStatementsClosed
This method explicitly removes the Statement from open statements list. 3. To close positioned update statements - These statements are not added to the list of open statements. -
markClosed
void markClosed(boolean removeListener) This method cleans up client-side resources held by this Statement. If removeListener is true, the Statement is removed from open statements list and PreparedStatement is also removed from commit and rollback listeners list. This is called from the close methods.- Parameters:
removeListener
- if true the Statement will be removed from the open statements list and PreparedStatement will also be removed from commit and rollback listeners list inorg.apache.derby.client.am.Connection
.
-
closeEverythingExceptResultSets
private void closeEverythingExceptResultSets(boolean removeListener) Close all resources except for ResultSets. This code was factored out of markClosed() so that closeMeOnCompletion() could close the Statement without having to re-close the already closed ResultSets. -
markPreparedStatementForAutoGeneratedKeysClosed
private void markPreparedStatementForAutoGeneratedKeysClosed() -
markResultSetsClosed
final void markResultSetsClosed(boolean removeListener) Mark all ResultSets associated with this statement as closed.- Parameters:
removeListener
- if true the ResultSets will be removed from the commit and rollback listeners list inorg.apache.derby.client.am.Connection
.
-
flowExecute
- Throws:
SqlException
-
flowExecuteBatch
- Throws:
SqlException
BatchUpdateException
-
writeExecuteCall
- Throws:
SqlException
-
listenToUnitOfWork
public void listenToUnitOfWork()- Specified by:
listenToUnitOfWork
in interfaceUnitOfWorkListener
-
completeLocalCommit
- Specified by:
completeLocalCommit
in interfaceUnitOfWorkListener
-
completeLocalRollback
- Specified by:
completeLocalRollback
in interfaceUnitOfWorkListener
-
accumulateWarning
- Specified by:
accumulateWarning
in interfaceStatementCallbackInterface
-
markPrepared
private void markPrepared() -
getJdbcStatementInterfaceName
Returns the name of the java.sql interface implemented by this class.- Returns:
- name of java.sql interface
-
parseSqlAndSetSqlModes
- Throws:
SqlException
-
isolateAnyInitialIdentifier
Minion of getStatementToken. If the input string starts with an identifier consisting of letters only (like "select", "update"..),return it, else return supplied string.- Parameters:
sql
- input string- Returns:
- identifier or unmodified string
- See Also:
-
getStatementToken
Step past any initial non-significant characters and comments to find first significant SQL token so we can classify statement.- Returns:
- first significant SQL token
- Throws:
SqlException
- std exception policy
-
parseUpdateSql
-
checkForAppropriateSqlMode
- Throws:
SqlException
-
checkResultSetCount
Checks that the number of result sets returned by the statement is consistent with the executed type.executeQuery()
should return exactly one result set andexecuteUpdate()
none. Raises an exception if the result set count does not match the execute type.- Parameters:
executeType
- one ofexecuteQueryMethod__
,executeUpdateMethod__
andexecuteMethod__
- Throws:
SqlException
- if the number of result sets does not match the execute type
-
checkForStoredProcResultSetCount
Checks that a stored procedure returns the correct number of result sets given its execute type. If the number is incorrect, make sure the transaction is rolled back when auto commit is enabled.- Parameters:
executeType
- one ofexecuteQueryMethod__
,executeUpdateMethod__
andexecuteMethod__
- Throws:
SqlException
- if the number of result sets does not match the execute type- See Also:
-
checkForClosedStatement
- Throws:
SqlException
-
checkForInvalidBatchedSql
- Throws:
SqlException
-
checkForDuplicateCursorName
- Throws:
SqlException
-
setupCursorNameCacheAndMappings
protected void setupCursorNameCacheAndMappings() -
extractCursorNameFromWhereCurrentOf
-
substituteClientCursorNameWithServerCursorName
protected String substituteClientCursorNameWithServerCursorName(String sql, Section section) throws SqlException - Throws:
SqlException
-
getConnectionCallbackInterface
- Specified by:
getConnectionCallbackInterface
in interfaceStatementCallbackInterface
-
resetCursorNameAndRemoveFromWhereCurrentOfMappings
void resetCursorNameAndRemoveFromWhereCurrentOfMappings() -
mapCursorNameToResultSet
private void mapCursorNameToResultSet() -
parseStorProcReturnedScrollableRowset
- Throws:
SqlException
-
escape
- Throws:
SqlException
-
cacheCursorAttributesToSendOnPrepare
- Throws:
SqlException
-
prepareAutoGeneratedKeysStatement
protected static ClientPreparedStatement prepareAutoGeneratedKeysStatement(ClientConnection cc) throws SqlException - Throws:
SqlException
-
checkAutoGeneratedKeysParameters
- Throws:
SqlException
-
getGuessedResultSetMetaData
- Specified by:
getGuessedResultSetMetaData
in interfaceStatementCallbackInterface
-
isQueryMode
public boolean isQueryMode() -
removeClientCursorNameFromCache
protected void removeClientCursorNameFromCache() -
resultSetCommitting
Convenience method for resultSetCommitting(ClientResultSet, boolean)- Parameters:
closingRS
- The ResultSet to be closed- Throws:
SqlException
- See Also:
-
resultSetCommitting
Method that checks to see if any other ResultSets are open. If not proceeds with the autocommit.- Parameters:
closingRS
- The ResultSet to be closedwriteChain
- A Boolean indicating whether this method is part of a chain of write from client to Server- Throws:
SqlException
-
markAutoCommitted
private void markAutoCommitted()Mark all ResultSets associated with this statement as auto-committed. -
closeOnCompletion
- Specified by:
closeOnCompletion
in interfaceStatement
- Throws:
SQLException
-
isCloseOnCompletion
- Specified by:
isCloseOnCompletion
in interfaceStatement
- Throws:
SQLException
-
closeMeOnCompletion
void closeMeOnCompletion() -
isOpen
- Throws:
SQLException
-
resetResultSetList
void resetResultSetList() -
getSection
Provides public access for section_. This is necessary as the section concept is shared between client.am and net. Seems like it really belongs in net as it is tied to the particular protocol used.- Returns:
- section_
-
setSection
Assigns a new value (even null) to section_. The existing section_ (if any) is freed.- Parameters:
s
- the section_ to set.
-