Package org.apache.derby.client.am
Class ClientStatement
- java.lang.Object
-
- org.apache.derby.client.am.ClientStatement
-
- All Implemented Interfaces:
java.lang.AutoCloseable,java.sql.Statement,java.sql.Wrapper,StatementCallbackInterface,UnitOfWorkListener
- Direct Known Subclasses:
ClientPreparedStatement
public class ClientStatement extends java.lang.Object implements java.sql.Statement, StatementCallbackInterface
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Agentagent_(package private) intautoGeneratedKeys_(package private) java.util.ArrayList<java.lang.Object>batch_CursorcachedCursor_CursorcachedSingletonRowData_private booleancloseOnCompletion_private booleanclosingResultSets_(package private) ClientConnectionconnection_java.lang.StringcursorAttributesToSendOnPrepare_(package private) java.lang.StringcursorName_protected booleandoWriteTimeout(package private) static intexecuteMethod__(package private) static intexecuteQueryMethod__(package private) static intexecuteUpdateMethod__(package private) intfetchDirection_private static longfetchedRowBaseFor use in debugging setLargeMaxRows() method added by JDBC 4.2(package private) intfetchSize_(package private) int[]generatedKeysColumnIndexes_(package private) java.lang.String[]generatedKeysColumnNames_(package private) ClientResultSetgeneratedKeysResultSet_private intindexOfCurrentResultSet_private static intINSIDE_BRACKETED_COMMENTprivate static intINSIDE_SIMPLECOMMENT(package private) booleanisAutoCommittableStatement_(package private) static intisCall__(package private) booleanisCatalogQuery_(package private) static intisDeleteSql__(package private) static intisInsertSql__protected booleanisPoolable(package private) booleanisPreparedStatement_(package private) static intisQuery__(package private) static intisUpdate__(package private) static intisUpdateSql__private MaterialStatementmaterialStatement_(package private) intmaxFieldSize_(package private) longmaxRows_(package private) booleanopenOnClient_private static intOUTSIDEState constants used by the FSM inside getStatementToken.private java.sql.StatementownerThe owner of this statement, if any.(package private) ClientPreparedStatementpreparedStatementForAutoGeneratedKeys_(package private) ClientResultSetresultSet_intresultSetConcurrency_(package private) intresultSetHoldability_(package private) ClientResultSet[]resultSetList_(package private) ColumnMetaDataresultSetMetaData_intresultSetType_private Sectionsection_private SectionsetSpecialRegisterSection_This variable keeps track of a Section dediacted to writeSpecialRegister.(package private) CursorsingletonRowData_protected intsqlMode_(package private) intsqlUpdateMode_(package private) inttimeout_protected static java.lang.StringTIMEOUT_STATEMENTprotected java.util.ArrayList<java.lang.String>timeoutArrayList(package private) longupdateCount_private SqlWarningwarnings_
-
Constructor Summary
Constructors Modifier Constructor Description privateClientStatement()ClientStatement(Agent agent, ClientConnection connection)ClientStatement(Agent agent, ClientConnection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccumulateWarning(SqlWarning e)voidaddBatch(java.lang.String sql)(package private) java.lang.StringcacheCursorAttributesToSendOnPrepare()voidcancel()(package private) voidcheckAutoGeneratedKeysParameters()(package private) voidcheckForAppropriateSqlMode(int executeType, int sqlMode)(package private) voidcheckForClosedStatement()protected voidcheckForDuplicateCursorName()private voidcheckForInvalidBatchedSql(java.lang.String sql)protected voidcheckForStoredProcResultSetCount(int executeType)Checks that a stored procedure returns the correct number of result sets given its execute type.private voidcheckResultSetCount(int executeType)Checks that the number of result sets returned by the statement is consistent with the executed type.voidclearBatch()voidclearWarnings()(package private) voidclearWarningsX()voidclose()private voidcloseEverythingExceptResultSets(boolean removeListener)Close all resources except for ResultSets.(package private) voidcloseMeOnCompletion()voidcloseOnCompletion()(package private) voidcloseX()An untraced version ofclose.voidcompleteExecute(Sqlca sqlca)voidcompleteExecuteCall(Sqlca sqlca, Cursor singletonParams)voidcompleteExecuteCall(Sqlca sqlca, Cursor singletonParams, ClientResultSet[] resultSets)voidcompleteExecuteCallOpenQuery(Sqlca sqlca, ClientResultSet resultSet, ColumnMetaData resultSetMetaData, Section generatedSection)voidcompleteExecuteImmediate(Sqlca sqlca)voidcompleteExecuteSetStatement(Sqlca sqlca)voidcompleteLocalCommit(java.util.Iterator listenerIterator)voidcompleteLocalRollback(java.util.Iterator listenerIterator)voidcompleteOpenQuery(Sqlca sqlca, ClientResultSet resultSet)voidcompletePrepare(Sqlca sqlca)voidcompletePrepareDescribeOutput(ColumnMetaData resultSetMetaData, Sqlca sqlca)intcompleteSqlca(Sqlca sqlca)(package private) java.lang.Stringescape(java.lang.String sql)booleanexecute(java.lang.String sql)booleanexecute(java.lang.String sql, int autoGeneratedKeys)booleanexecute(java.lang.String sql, int[] columnIndexes)booleanexecute(java.lang.String sql, java.lang.String[] columnNames)int[]executeBatch()private long[]executeBatchX()long[]executeLargeBatch()longexecuteLargeUpdate(java.lang.String sql)longexecuteLargeUpdate(java.lang.String sql, int autoGeneratedKeys)longexecuteLargeUpdate(java.lang.String sql, int[] columnIndexes)longexecuteLargeUpdate(java.lang.String sql, java.lang.String[] columnNames)java.sql.ResultSetexecuteQuery(java.lang.String sql)private ClientResultSetexecuteQueryX(java.lang.String sql)intexecuteUpdate(java.lang.String sql)intexecuteUpdate(java.lang.String sql, int autoGeneratedKeys)intexecuteUpdate(java.lang.String sql, int[] columnIndexes)intexecuteUpdate(java.lang.String sql, java.lang.String[] columnNames)private longexecuteUpdateX(java.lang.String sql)(package private) booleanexecuteX(java.lang.String sql)(package private) java.lang.String[]extractCursorNameFromWhereCurrentOf(java.lang.String sql)protected voidfinalize()private voidflowClose()private voidflowCloseOutsideUOW()private voidflowCloseRetrievedResultSets()private voidflowCloseRetrievedResultSetsOutsideUOW()private voidflowExecute(int executeType, java.lang.String sql)private voidflowExecuteBatch(long[] updateCounts)java.sql.ConnectiongetConnection()ConnectionCallbackInterfacegetConnectionCallbackInterface()intgetFetchDirection()intgetFetchSize()java.sql.ResultSetgetGeneratedKeys()ColumnMetaDatagetGuessedResultSetMetaData()protected java.lang.StringgetJdbcStatementInterfaceName()Returns the name of the java.sql interface implemented by this class.longgetLargeMaxRows()longgetLargeUpdateCount()MaterialStatementgetMaterialStatement()intgetMaxFieldSize()intgetMaxRows()booleangetMoreResults()booleangetMoreResults(int current)private booleangetMoreResultsX(int current)(package private) java.sql.StatementgetOwner()Returns the owner of this statement, if any.intgetQueryTimeout()java.sql.ResultSetgetResultSet()intgetResultSetConcurrency()intgetResultSetHoldability()intgetResultSetType()SectiongetSection()Provides public access for section_.protected SqlWarninggetSqlWarnings()private java.lang.StringgetStatementToken(java.lang.String sql)Step past any initial non-significant characters and comments to find first significant SQL token so we can classify statement.intgetUpdateCount()java.sql.SQLWarninggetWarnings()protected voidinitResetPreparedStatement()private voidinitResetStatement()private voidinitStatement()private voidinitStatement(int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)private voidinitStatement(Agent agent, ClientConnection connection)booleanisClosed()Tell whether the statement has been closed or not.booleanisCloseOnCompletion()private java.lang.StringisolateAnyInitialIdentifier(java.lang.String sql)Minion of getStatementToken.private booleanisOpen(ClientResultSet rs)booleanisPoolable()Returns the value of the poolable hint, indicating whether pooling is requested.booleanisQueryMode()booleanisWrapperFor(java.lang.Class<?> iface)Returns false unlessifaceis implementedvoidlistenToUnitOfWork()private voidmapCursorNameToResultSet()private voidmarkAutoCommitted()Mark all ResultSets associated with this statement as auto-committed.(package private) voidmarkClosed()This method cleans up client-side resources held by this Statement.(package private) voidmarkClosed(boolean removeListener)This method cleans up client-side resources held by this Statement.private voidmarkPrepared()private voidmarkPreparedStatementForAutoGeneratedKeysClosed()(package private) voidmarkResultSetsClosed(boolean removeListener)Mark all ResultSets associated with this statement as closed.(package private) voidparseSqlAndSetSqlModes(java.lang.String sql)(package private) voidparseStorProcReturnedScrollableRowset()private voidparseUpdateSql(java.lang.String firstToken)protected static ClientPreparedStatementprepareAutoGeneratedKeysStatement(ClientConnection cc)(package private) voidreadClose(boolean allowAutoCommits)(package private) voidreadCloseResultSets(boolean allowAutoCommits)private voidreadCloseResultSets(int number, boolean allowAutoCommits)(package private) voidreadExecuteCall()private voidreadExecuteImmediate()private voidreadExecuteImmediateForBatch(java.lang.String sql)(package private) voidreadOpenQuery()(package private) voidreadPrepare()(package private) voidreadPrepareDescribeOutput()(package private) voidreadSetSpecialRegister()protected voidremoveClientCursorNameFromCache()voidreset(boolean fullReset)(package private) voidresetCursorNameAndRemoveFromWhereCurrentOfMappings()(package private) voidresetForReuse()Resets the statement for reuse in a statement pool.(package private) voidresetResultSetList()private voidresetStatement()(package private) voidresetStatement(Agent agent, ClientConnection connection)voidresetStatement(Agent agent, ClientConnection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)private voidresetUserControllableAttributes()Resets attributes that can be modified by the user through theStatementinterface to default values.(package private) voidresultSetCommitting(ClientResultSet closingRS)Convenience method for resultSetCommitting(ClientResultSet, boolean)(package private) booleanresultSetCommitting(ClientResultSet closingRS, boolean writeChain)Method that checks to see if any other ResultSets are open.voidsetCursorName(java.lang.String name)voidsetEscapeProcessing(boolean enable)voidsetFetchDirection(int direction)static voidsetFetchedRowBase(long newBase)Debug method used to test the setLargeMaxRows() method added by JDBC 4.2.voidsetFetchSize(int rows)voidsetLargeMaxRows(long maxRows)voidsetMaterialStatement(MaterialStatement materialStatement)voidsetMaxFieldSize(int max)voidsetMaxRows(int maxRows)protected voidsetOwner(java.sql.Statement owner)Designates the owner of this statement, typically a logical statement.voidsetPoolable(boolean poolable)Requests that a Statement be pooled or not.voidsetQueryTimeout(int seconds)protected voidsetSection(Section s)Assigns a new value (even null) to section_.protected voidsetupCursorNameCacheAndMappings()voidsetUpdateCount(long updateCount)protected java.lang.StringsubstituteClientCursorNameWithServerCursorName(java.lang.String sql, Section section)<T> Tunwrap(java.lang.Class<T> iface)Returnsthisif this class implements the specified interface.private booleanwillTickleServer(int number, boolean allowAutoCommits)(package private) voidwriteClose(boolean allowAutoCommits)(package private) booleanwriteCloseResultSets(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 booleanwriteCloseResultSets(int number, boolean allowAutoCommits)(package private) voidwriteExecuteCall(boolean outputExpected, java.lang.String procedureName, Section section, int fetchSize, boolean suppressResultSets, int resultSetType, ColumnMetaData parameterMetaData, java.lang.Object[] inputs)private SectionwriteExecuteCall(java.lang.String sql, boolean isBatch)private voidwriteExecuteImmediate(java.lang.String sql, Section section)(package private) voidwriteOpenQuery(Section section, int fetchSize, int resultSetType)(package private) voidwritePrepare(java.lang.String sql, Section section)(package private) voidwritePrepareDescribeOutput(java.lang.String sql, Section section)(package private) voidwriteSetSpecialRegister(java.util.ArrayList sqlsttList)
-
-
-
Field Detail
-
fetchedRowBase
private static long fetchedRowBase
For use in debugging setLargeMaxRows() method added by JDBC 4.2
-
materialStatement_
private MaterialStatement materialStatement_
-
connection_
ClientConnection connection_
-
section_
private Section section_
-
agent_
Agent agent_
-
owner
private java.sql.Statement owner
The owner of this statement, if any.
-
resultSet_
ClientResultSet resultSet_
-
updateCount_
long updateCount_
-
executeQueryMethod__
static final int executeQueryMethod__
- See Also:
- Constant Field Values
-
executeUpdateMethod__
static final int executeUpdateMethod__
- See Also:
- Constant Field Values
-
executeMethod__
static final int executeMethod__
- See Also:
- Constant Field Values
-
sqlMode_
protected int sqlMode_
-
isQuery__
static final int isQuery__
- See Also:
- Constant Field Values
-
isCall__
static final int isCall__
- See Also:
- Constant Field Values
-
isUpdate__
static final int isUpdate__
- See Also:
- Constant Field Values
-
sqlUpdateMode_
int sqlUpdateMode_
-
isInsertSql__
static final int isInsertSql__
- See Also:
- Constant Field Values
-
isDeleteSql__
static final int isDeleteSql__
- See Also:
- Constant Field Values
-
isUpdateSql__
static final int isUpdateSql__
- See Also:
- Constant Field Values
-
resultSetMetaData_
ColumnMetaData resultSetMetaData_
-
cachedCursor_
public Cursor cachedCursor_
-
cachedSingletonRowData_
public Cursor cachedSingletonRowData_
-
isPreparedStatement_
boolean isPreparedStatement_
-
cursorName_
java.lang.String cursorName_
-
openOnClient_
boolean openOnClient_
-
indexOfCurrentResultSet_
private int indexOfCurrentResultSet_
-
resultSetList_
ClientResultSet[] resultSetList_
-
TIMEOUT_STATEMENT
protected static final java.lang.String TIMEOUT_STATEMENT
- See Also:
- Constant Field Values
-
timeoutArrayList
protected java.util.ArrayList<java.lang.String> timeoutArrayList
-
doWriteTimeout
protected boolean doWriteTimeout
-
timeout_
int timeout_
-
maxRows_
long maxRows_
-
maxFieldSize_
int maxFieldSize_
-
isAutoCommittableStatement_
boolean isAutoCommittableStatement_
-
isCatalogQuery_
boolean isCatalogQuery_
-
batch_
final java.util.ArrayList<java.lang.Object> batch_
-
resultSetType_
public int resultSetType_
-
resultSetConcurrency_
public int resultSetConcurrency_
-
resultSetHoldability_
int resultSetHoldability_
-
fetchSize_
int fetchSize_
-
fetchDirection_
int fetchDirection_
-
singletonRowData_
Cursor singletonRowData_
-
cursorAttributesToSendOnPrepare_
public java.lang.String cursorAttributesToSendOnPrepare_
-
preparedStatementForAutoGeneratedKeys_
ClientPreparedStatement preparedStatementForAutoGeneratedKeys_
-
generatedKeysResultSet_
ClientResultSet generatedKeysResultSet_
-
generatedKeysColumnNames_
java.lang.String[] generatedKeysColumnNames_
-
generatedKeysColumnIndexes_
int[] generatedKeysColumnIndexes_
-
autoGeneratedKeys_
int autoGeneratedKeys_
-
warnings_
private SqlWarning warnings_
-
isPoolable
protected boolean isPoolable
-
closeOnCompletion_
private boolean closeOnCompletion_
-
closingResultSets_
private boolean closingResultSets_
-
setSpecialRegisterSection_
private Section 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 OUTSIDE
State constants used by the FSM inside getStatementToken.
-
INSIDE_SIMPLECOMMENT
private static final int INSIDE_SIMPLECOMMENT
- See Also:
- Constant Field Values
-
INSIDE_BRACKETED_COMMENT
private static final int INSIDE_BRACKETED_COMMENT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ClientStatement
private ClientStatement()
-
ClientStatement
public ClientStatement(Agent agent, ClientConnection connection) throws SqlException
- Throws:
SqlException
-
ClientStatement
public ClientStatement(Agent agent, ClientConnection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes) throws SqlException
- Throws:
SqlException
-
-
Method Detail
-
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
public MaterialStatement getMaterialStatement()
- Returns:
- the materialStatement
-
setMaterialStatement
public void setMaterialStatement(MaterialStatement materialStatement)
- 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 theStatementinterface to default values.
-
reset
public void reset(boolean fullReset) throws SqlException- Throws:
SqlException
-
resetForReuse
void resetForReuse() throws SqlExceptionResets the statement for reuse in a statement pool.Intended to be used only by prepared or callable statements, as
Statementobjects 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
void resetStatement(Agent agent, ClientConnection connection) throws SqlException
- Throws:
SqlException
-
initStatement
private void initStatement(Agent agent, ClientConnection connection)
-
resetStatement
public void resetStatement(Agent agent, ClientConnection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes) throws SqlException
- Throws:
SqlException
-
initStatement
private void initStatement(int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes) throws SqlException- Throws:
SqlException
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
getSqlWarnings
protected SqlWarning getSqlWarnings()
-
executeQuery
public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException- Specified by:
executeQueryin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeQueryX
private ClientResultSet executeQueryX(java.lang.String sql) throws SqlException
- Throws:
SqlException
-
executeUpdate
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException- Specified by:
executeUpdatein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeLargeUpdate
public long executeLargeUpdate(java.lang.String sql) throws java.sql.SQLException- Specified by:
executeLargeUpdatein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeUpdateX
private long executeUpdateX(java.lang.String sql) throws SqlException- Throws:
SqlException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLExceptionReturns false unlessifaceis implemented- Specified by:
isWrapperForin interfacejava.sql.Wrapper- Parameters:
iface- a Class defining an interface.- Returns:
- true if this implements the interface or directly or indirectly wraps an object that does.
- Throws:
java.sql.SQLException- if an error occurs while determining whether this is a wrapper for an object with the given interface.
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLExceptionReturnsthisif this class implements the specified interface.- Specified by:
unwrapin interfacejava.sql.Wrapper- Parameters:
iface- a class defining an interface- Returns:
- an object that implements the interface
- Throws:
java.sql.SQLException- if no object is found that implements the interface
-
isClosed
public boolean isClosed() throws java.sql.SQLExceptionTell whether the statement has been closed or not.- Specified by:
isClosedin interfacejava.sql.Statement- Returns:
trueif closed,falseotherwise.- Throws:
java.sql.SQLException- if a database access error occurs (according to spec). Never thrown by this implementation.
-
close
public void close() throws java.sql.SQLException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
closeX
void closeX() throws SqlExceptionAn 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 betweenfinalizeandcloseis 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
public boolean isPoolable() throws java.sql.SQLExceptionReturns the value of the poolable hint, indicating whether pooling is requested.- Specified by:
isPoolablein interfacejava.sql.Statement- Returns:
- The value of the poolable hint.
- Throws:
java.sql.SQLException- if the Statement has been closed.
-
setPoolable
public void setPoolable(boolean poolable) throws java.sql.SQLExceptionRequests that a Statement be pooled or not.- Specified by:
setPoolablein interfacejava.sql.Statement- Parameters:
poolable- requests that the Statement be pooled if true and not be pooled if false.- Throws:
java.sql.SQLException- if the Statement has been closed.
-
getMaxFieldSize
public int getMaxFieldSize() throws java.sql.SQLException- Specified by:
getMaxFieldSizein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
setMaxFieldSize
public void setMaxFieldSize(int max) throws java.sql.SQLException- Specified by:
setMaxFieldSizein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getMaxRows
public int getMaxRows() throws java.sql.SQLException- Specified by:
getMaxRowsin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getLargeMaxRows
public long getLargeMaxRows() throws java.sql.SQLException- Specified by:
getLargeMaxRowsin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
setMaxRows
public void setMaxRows(int maxRows) throws java.sql.SQLException- Specified by:
setMaxRowsin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
setLargeMaxRows
public void setLargeMaxRows(long maxRows) throws java.sql.SQLException- Specified by:
setLargeMaxRowsin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
setEscapeProcessing
public void setEscapeProcessing(boolean enable) throws java.sql.SQLException- Specified by:
setEscapeProcessingin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getQueryTimeout
public int getQueryTimeout() throws java.sql.SQLException- Specified by:
getQueryTimeoutin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
setQueryTimeout
public void setQueryTimeout(int seconds) throws java.sql.SQLException- Specified by:
setQueryTimeoutin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
cancel
public void cancel() throws java.sql.SQLException- Specified by:
cancelin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException- Specified by:
getWarningsin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
clearWarnings
public void clearWarnings() throws java.sql.SQLException- Specified by:
clearWarningsin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
clearWarningsX
final void clearWarningsX()
-
setCursorName
public void setCursorName(java.lang.String name) throws java.sql.SQLException- Specified by:
setCursorNamein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
execute
public boolean execute(java.lang.String sql) throws java.sql.SQLException- Specified by:
executein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeX
boolean executeX(java.lang.String sql) throws SqlException- Throws:
SqlException
-
getResultSet
public java.sql.ResultSet getResultSet() throws java.sql.SQLException- Specified by:
getResultSetin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getUpdateCount
public int getUpdateCount() throws java.sql.SQLException- Specified by:
getUpdateCountin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getLargeUpdateCount
public long getLargeUpdateCount() throws java.sql.SQLException- Specified by:
getLargeUpdateCountin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getMoreResults
public boolean getMoreResults() throws java.sql.SQLException- Specified by:
getMoreResultsin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
setFetchDirection
public void setFetchDirection(int direction) throws java.sql.SQLException- Specified by:
setFetchDirectionin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getFetchDirection
public int getFetchDirection() throws java.sql.SQLException- Specified by:
getFetchDirectionin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
setFetchSize
public void setFetchSize(int rows) throws java.sql.SQLException- Specified by:
setFetchSizein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getFetchSize
public int getFetchSize() throws java.sql.SQLException- Specified by:
getFetchSizein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getResultSetConcurrency
public int getResultSetConcurrency() throws java.sql.SQLException- Specified by:
getResultSetConcurrencyin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getResultSetType
public int getResultSetType() throws java.sql.SQLException- Specified by:
getResultSetTypein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
addBatch
public void addBatch(java.lang.String sql) throws java.sql.SQLException- Specified by:
addBatchin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
clearBatch
public void clearBatch() throws java.sql.SQLException- Specified by:
clearBatchin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeBatch
public int[] executeBatch() throws java.sql.SQLException- Specified by:
executeBatchin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeLargeBatch
public long[] executeLargeBatch() throws java.sql.SQLException- Specified by:
executeLargeBatchin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeBatchX
private long[] executeBatchX() throws SqlException, java.sql.BatchUpdateException- Throws:
SqlExceptionjava.sql.BatchUpdateException
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException- Specified by:
getConnectionin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getMoreResults
public boolean getMoreResults(int current) throws java.sql.SQLException- Specified by:
getMoreResultsin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getMoreResultsX
private boolean getMoreResultsX(int current) throws SqlException- Throws:
SqlException
-
getGeneratedKeys
public java.sql.ResultSet getGeneratedKeys() throws java.sql.SQLException- Specified by:
getGeneratedKeysin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeUpdate
public int executeUpdate(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException- Specified by:
executeUpdatein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeLargeUpdate
public long executeLargeUpdate(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException- Specified by:
executeLargeUpdatein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeUpdate
public int executeUpdate(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException- Specified by:
executeUpdatein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeLargeUpdate
public long executeLargeUpdate(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException- Specified by:
executeLargeUpdatein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeUpdate
public int executeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException- Specified by:
executeUpdatein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeLargeUpdate
public long executeLargeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException- Specified by:
executeLargeUpdatein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
execute
public boolean execute(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException- Specified by:
executein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
execute
public boolean execute(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException- Specified by:
executein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
execute
public boolean execute(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException- Specified by:
executein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
getResultSetHoldability
public int getResultSetHoldability() throws java.sql.SQLException- Specified by:
getResultSetHoldabilityin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
writeSetSpecialRegister
void writeSetSpecialRegister(java.util.ArrayList sqlsttList) throws SqlException- Throws:
SqlException
-
readSetSpecialRegister
void readSetSpecialRegister() throws SqlException- Throws:
SqlException
-
writeExecuteImmediate
private void writeExecuteImmediate(java.lang.String sql, Section section) throws SqlException- Throws:
SqlException
-
readExecuteImmediate
private void readExecuteImmediate() throws SqlException- Throws:
SqlException
-
completeExecuteImmediate
public void completeExecuteImmediate(Sqlca sqlca)
- Specified by:
completeExecuteImmediatein interfaceStatementCallbackInterface
-
readExecuteImmediateForBatch
private void readExecuteImmediateForBatch(java.lang.String sql) throws SqlException- Throws:
SqlException
-
writePrepareDescribeOutput
void writePrepareDescribeOutput(java.lang.String sql, Section section) throws SqlException- Throws:
SqlException
-
readPrepareDescribeOutput
void readPrepareDescribeOutput() throws SqlException- Throws:
SqlException
-
completePrepareDescribeOutput
public void completePrepareDescribeOutput(ColumnMetaData resultSetMetaData, Sqlca sqlca)
- Specified by:
completePrepareDescribeOutputin interfaceStatementCallbackInterface
-
writePrepare
void writePrepare(java.lang.String sql, Section section) throws SqlException- Throws:
SqlException
-
readPrepare
void readPrepare() throws SqlException- Throws:
SqlException
-
completePrepare
public void completePrepare(Sqlca sqlca)
- Specified by:
completePreparein interfaceStatementCallbackInterface
-
writeOpenQuery
void writeOpenQuery(Section section, int fetchSize, int resultSetType) throws SqlException
- Throws:
SqlException
-
readOpenQuery
void readOpenQuery() throws SqlException- Throws:
SqlException
-
completeOpenQuery
public void completeOpenQuery(Sqlca sqlca, ClientResultSet resultSet)
- Specified by:
completeOpenQueryin interfaceStatementCallbackInterface
-
completeExecuteCallOpenQuery
public void completeExecuteCallOpenQuery(Sqlca sqlca, ClientResultSet resultSet, ColumnMetaData resultSetMetaData, Section generatedSection)
- Specified by:
completeExecuteCallOpenQueryin interfaceStatementCallbackInterface
-
writeExecuteCall
void writeExecuteCall(boolean outputExpected, java.lang.String procedureName, Section section, int fetchSize, boolean suppressResultSets, int resultSetType, ColumnMetaData parameterMetaData, java.lang.Object[] inputs) throws SqlException- Throws:
SqlException
-
readExecuteCall
void readExecuteCall() throws SqlException- Throws:
SqlException
-
completeExecuteCall
public void completeExecuteCall(Sqlca sqlca, Cursor singletonParams, ClientResultSet[] resultSets)
- Specified by:
completeExecuteCallin interfaceStatementCallbackInterface
-
completeExecuteCall
public void completeExecuteCall(Sqlca sqlca, Cursor singletonParams)
- Specified by:
completeExecuteCallin interfaceStatementCallbackInterface
-
completeExecute
public void completeExecute(Sqlca sqlca)
- Specified by:
completeExecutein interfaceStatementCallbackInterface
-
setUpdateCount
public void setUpdateCount(long updateCount)
-
setOwner
protected final void setOwner(java.sql.Statement owner)
Designates the owner of this statement, typically a logical statement.- Parameters:
owner- the owning statement, if any
-
getOwner
final java.sql.Statement getOwner()
Returns the owner of this statement, if any.- Returns:
- The designated owner of this statement, or
nullif none.
-
willTickleServer
private boolean willTickleServer(int number, boolean allowAutoCommits) throws SqlException- Throws:
SqlException
-
flowClose
private void flowClose() throws SqlException- Throws:
SqlException
-
flowCloseOutsideUOW
private void flowCloseOutsideUOW() throws SqlException- Throws:
SqlException
-
writeClose
final void writeClose(boolean allowAutoCommits) throws SqlException- Throws:
SqlException
-
readClose
final void readClose(boolean allowAutoCommits) throws SqlException- Throws:
SqlException
-
writeCloseResultSets
final boolean writeCloseResultSets(boolean allowAutoCommits) throws SqlExceptionThe 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
private boolean writeCloseResultSets(int number, boolean allowAutoCommits) throws SqlException- Throws:
SqlException
-
readCloseResultSets
final void readCloseResultSets(boolean allowAutoCommits) throws SqlException- Throws:
SqlException
-
readCloseResultSets
private void readCloseResultSets(int number, boolean allowAutoCommits) throws SqlException- Throws:
SqlException
-
flowCloseRetrievedResultSets
private void flowCloseRetrievedResultSets() throws SqlException- Throws:
SqlException
-
flowCloseRetrievedResultSetsOutsideUOW
private void flowCloseRetrievedResultSetsOutsideUOW() throws SqlException- Throws:
SqlException
-
completeSqlca
public int completeSqlca(Sqlca sqlca)
- Specified by:
completeSqlcain interfaceStatementCallbackInterface
-
completeExecuteSetStatement
public void completeExecuteSetStatement(Sqlca sqlca)
- Specified by:
completeExecuteSetStatementin 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#markStatementsClosedThis 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
private void flowExecute(int executeType, java.lang.String sql) throws SqlException- Throws:
SqlException
-
flowExecuteBatch
private void flowExecuteBatch(long[] updateCounts) throws SqlException, java.sql.BatchUpdateException- Throws:
SqlExceptionjava.sql.BatchUpdateException
-
writeExecuteCall
private Section writeExecuteCall(java.lang.String sql, boolean isBatch) throws SqlException
- Throws:
SqlException
-
listenToUnitOfWork
public void listenToUnitOfWork()
- Specified by:
listenToUnitOfWorkin interfaceUnitOfWorkListener
-
completeLocalCommit
public void completeLocalCommit(java.util.Iterator listenerIterator)
- Specified by:
completeLocalCommitin interfaceUnitOfWorkListener
-
completeLocalRollback
public void completeLocalRollback(java.util.Iterator listenerIterator)
- Specified by:
completeLocalRollbackin interfaceUnitOfWorkListener
-
accumulateWarning
public void accumulateWarning(SqlWarning e)
- Specified by:
accumulateWarningin interfaceStatementCallbackInterface
-
markPrepared
private void markPrepared()
-
getJdbcStatementInterfaceName
protected java.lang.String getJdbcStatementInterfaceName()
Returns the name of the java.sql interface implemented by this class.- Returns:
- name of java.sql interface
-
parseSqlAndSetSqlModes
void parseSqlAndSetSqlModes(java.lang.String sql) throws SqlException- Throws:
SqlException
-
isolateAnyInitialIdentifier
private java.lang.String isolateAnyInitialIdentifier(java.lang.String sql)
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(java.lang.String)
-
getStatementToken
private java.lang.String getStatementToken(java.lang.String sql) throws SqlExceptionStep 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
private void parseUpdateSql(java.lang.String firstToken)
-
checkForAppropriateSqlMode
final void checkForAppropriateSqlMode(int executeType, int sqlMode) throws SqlException- Throws:
SqlException
-
checkResultSetCount
private void checkResultSetCount(int executeType) throws SqlExceptionChecks 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
protected final void checkForStoredProcResultSetCount(int executeType) throws SqlExceptionChecks 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:
checkResultSetCount(int)
-
checkForClosedStatement
final void checkForClosedStatement() throws SqlException- Throws:
SqlException
-
checkForInvalidBatchedSql
private void checkForInvalidBatchedSql(java.lang.String sql) throws SqlException- Throws:
SqlException
-
checkForDuplicateCursorName
protected void checkForDuplicateCursorName() throws SqlException- Throws:
SqlException
-
setupCursorNameCacheAndMappings
protected void setupCursorNameCacheAndMappings()
-
extractCursorNameFromWhereCurrentOf
java.lang.String[] extractCursorNameFromWhereCurrentOf(java.lang.String sql)
-
substituteClientCursorNameWithServerCursorName
protected java.lang.String substituteClientCursorNameWithServerCursorName(java.lang.String sql, Section section) throws SqlException- Throws:
SqlException
-
getConnectionCallbackInterface
public ConnectionCallbackInterface getConnectionCallbackInterface()
- Specified by:
getConnectionCallbackInterfacein interfaceStatementCallbackInterface
-
resetCursorNameAndRemoveFromWhereCurrentOfMappings
void resetCursorNameAndRemoveFromWhereCurrentOfMappings()
-
mapCursorNameToResultSet
private void mapCursorNameToResultSet()
-
parseStorProcReturnedScrollableRowset
void parseStorProcReturnedScrollableRowset() throws SqlException- Throws:
SqlException
-
escape
java.lang.String escape(java.lang.String sql) throws SqlException- Throws:
SqlException
-
cacheCursorAttributesToSendOnPrepare
java.lang.String cacheCursorAttributesToSendOnPrepare() throws SqlException- Throws:
SqlException
-
prepareAutoGeneratedKeysStatement
protected static ClientPreparedStatement prepareAutoGeneratedKeysStatement(ClientConnection cc) throws SqlException
- Throws:
SqlException
-
checkAutoGeneratedKeysParameters
void checkAutoGeneratedKeysParameters() throws SqlException- Throws:
SqlException
-
getGuessedResultSetMetaData
public ColumnMetaData getGuessedResultSetMetaData()
- Specified by:
getGuessedResultSetMetaDatain interfaceStatementCallbackInterface
-
isQueryMode
public boolean isQueryMode()
-
removeClientCursorNameFromCache
protected void removeClientCursorNameFromCache()
-
resultSetCommitting
void resultSetCommitting(ClientResultSet closingRS) throws SqlException
Convenience method for resultSetCommitting(ClientResultSet, boolean)- Parameters:
closingRS- The ResultSet to be closed- Throws:
SqlException- See Also:
resultSetCommitting(ClientResultSet, boolean)
-
resultSetCommitting
boolean resultSetCommitting(ClientResultSet closingRS, boolean writeChain) throws SqlException
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
public void closeOnCompletion() throws java.sql.SQLException- Specified by:
closeOnCompletionin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
isCloseOnCompletion
public boolean isCloseOnCompletion() throws java.sql.SQLException- Specified by:
isCloseOnCompletionin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
closeMeOnCompletion
void closeMeOnCompletion()
-
isOpen
private boolean isOpen(ClientResultSet rs) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
resetResultSetList
void resetResultSetList()
-
getSection
public Section 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
protected void setSection(Section s)
Assigns a new value (even null) to section_. The existing section_ (if any) is freed.- Parameters:
s- the section_ to set.
-
-