org.apache.derby.client.am
Class Statement

java.lang.Object
  extended by org.apache.derby.client.am.Statement
All Implemented Interfaces:
java.sql.Statement, java.sql.Wrapper, StatementCallbackInterface, UnitOfWorkListener
Direct Known Subclasses:
PreparedStatement, Statement40

public class Statement
extends java.lang.Object
implements java.sql.Statement, StatementCallbackInterface


Field Summary
(package private)  Agent agent_
           
 int autoGeneratedKeys_
           
(package private)  java.util.ArrayList batch_
           
 Cursor cachedCursor_
           
 Cursor cachedSingletonRowData_
           
static int CLOSE_ALL_RESULTS
           
static int CLOSE_CURRENT_RESULT
           
(package private)  Connection connection_
           
 java.lang.String cursorAttributesToSendOnPrepare_
           
(package private)  java.lang.String cursorName_
           
protected  boolean doWriteTimeout
           
(package private) static int executeMethod__
           
(package private) static int executeQueryMethod__
           
(package private) static int executeUpdateMethod__
           
 int fetchDirection_
           
 int fetchSize_
           
 int[] generatedKeysColumnIndexes_
           
 java.lang.String[] generatedKeysColumnNames_
           
 ResultSet generatedKeysResultSet_
           
protected  int indexOfCurrentResultSet_
           
private static int INSIDE_BRACKETED_COMMENT
           
private static int INSIDE_SIMPLECOMMENT
           
(package private)  boolean isAutoCommittableStatement_
           
(package private) static int isCall__
           
(package private)  boolean isCatalogQuery_
           
static int isCommitSql__
           
(package private) static int isDeleteSql__
           
(package private) static int isInsertSql__
           
protected  boolean isPoolable
           
(package private) static int isPositionedUpdateDeleteSql__
           
(package private)  boolean isPreparedStatement_
           
(package private) static int isQuery__
           
static int isRollbackSql__
           
(package private) static int isUpdate__
           
(package private) static int isUpdateSql__
           
static int KEEP_CURRENT_RESULT
           
 MaterialStatement materialStatement_
           
(package private)  int maxFieldSize_
           
(package private)  int maxRows_
           
 int numInvisibleRS_
           
(package private)  boolean openOnClient_
           
(package private)  boolean openOnServer_
           
private static int OUTSIDE
          State constants used by the FSM inside getStatementToken.
private  java.sql.Statement owner
          The owner of this statement, if any.
 PreparedStatement preparedStatementForAutoGeneratedKeys_
           
(package private)  ResultSet resultSet_
           
 int resultSetConcurrency_
           
 int resultSetHoldability_
           
(package private)  ResultSet[] resultSetList_
           
(package private)  ColumnMetaData resultSetMetaData_
           
 int resultSetType_
           
(package private)  int returnValueFromProcedure_
           
 Section section_
           
private  Section setSpecialRegisterSection_
          This variable keeps track of a Section dediacted to writeSpecialRegister.
 Cursor singletonRowData_
           
protected  int sqlMode_
           
(package private)  int sqlUpdateMode_
           
(package private)  int timeout_
           
protected static java.lang.String TIMEOUT_STATEMENT
           
protected  java.util.ArrayList timeoutArrayList
           
(package private)  int updateCount_
           
private  SqlWarning warnings_
           
 
Fields inherited from interface java.sql.Statement
EXECUTE_FAILED, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
 
Constructor Summary
private Statement()
           
  Statement(Agent agent, Connection connection)
           
  Statement(Agent agent, Connection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)
           
 
Method Summary
 void accumulateWarning(SqlWarning e)
           
 void addBatch(java.lang.String sql)
           
(package private)  java.lang.String cacheCursorAttributesToSendOnPrepare()
           
 void cancel()
           
(package private)  void checkAutoGeneratedKeysParameters()
           
(package private)  void checkForAppropriateSqlMode(int executeType, int sqlMode)
           
(package private)  void checkForClosedStatement()
           
protected  void checkForDuplicateCursorName()
           
(package private)  void checkForInvalidBatchedSql(java.lang.String sql)
           
protected  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 clearBatch()
           
 void clearWarnings()
           
(package private)  void clearWarningsX()
           
 void close()
           
 void closeX()
          An untraced version of close.
 void completeExecute(Sqlca sqlca)
           
 void completeExecuteCall(Sqlca sqlca, Cursor singletonParams)
           
 void completeExecuteCall(Sqlca sqlca, Cursor singletonParams, ResultSet[] resultSets)
           
 void completeExecuteCallOpenQuery(Sqlca sqlca, ResultSet resultSet, ColumnMetaData resultSetMetaData, Section generatedSection)
           
 void completeExecuteImmediate(Sqlca sqlca)
           
 void completeExecuteSetStatement(Sqlca sqlca)
           
 void completeLocalCommit(java.util.Iterator listenerIterator)
           
 void completeLocalRollback(java.util.Iterator listenerIterator)
           
 void completeOpenQuery(Sqlca sqlca, ResultSet resultSet)
           
 void completePrepare(Sqlca sqlca)
           
 void completePrepareDescribeOutput(ColumnMetaData resultSetMetaData, Sqlca sqlca)
           
 int completeSqlca(Sqlca sqlca)
           
(package private)  java.lang.String escape(java.lang.String sql)
           
 boolean execute(java.lang.String sql)
           
 boolean execute(java.lang.String sql, int autoGeneratedKeys)
           
 boolean execute(java.lang.String sql, int[] columnIndexes)
           
 boolean execute(java.lang.String sql, java.lang.String[] columnNames)
           
 int[] executeBatch()
           
private  int[] executeBatchX()
           
 java.sql.ResultSet executeQuery(java.lang.String sql)
           
private  ResultSet executeQueryX(java.lang.String sql)
           
 int executeUpdate(java.lang.String sql)
           
 int executeUpdate(java.lang.String sql, int autoGeneratedKeys)
           
 int executeUpdate(java.lang.String sql, int[] columnIndexes)
           
 int executeUpdate(java.lang.String sql, java.lang.String[] columnNames)
           
private  int executeUpdateX(java.lang.String sql)
           
(package private)  boolean executeX(java.lang.String sql)
           
(package private)  java.lang.String[] extractCursorNameFromWhereCurrentOf(java.lang.String sql)
           
protected  void finalize()
           
private  void flowClose()
           
private  void flowCloseOutsideUOW()
           
private  void flowCloseRetrievedResultSets()
           
private  void flowCloseRetrievedResultSetsOutsideUOW()
           
private  void flowExecute(int executeType, java.lang.String sql)
           
(package private)  void flowExecuteBatch(int[] updateCounts)
           
 java.sql.Connection getConnection()
           
 ConnectionCallbackInterface getConnectionCallbackInterface()
           
 int getFetchDirection()
           
 int getFetchSize()
           
 java.sql.ResultSet getGeneratedKeys()
           
 ColumnMetaData getGuessedResultSetMetaData()
           
protected  java.lang.String getJdbcStatementInterfaceName()
          Returns the name of the java.sql interface implemented by this class.
 int getMaxFieldSize()
           
 int getMaxRows()
           
 boolean getMoreResults()
           
 boolean getMoreResults(int current)
           
private  boolean getMoreResultsX(int current)
           
(package private)  java.sql.Statement getOwner()
          Returns the owner of this statement, if any.
(package private)  void getPreparedStatementForAutoGeneratedKeys()
           
(package private)  java.lang.String getProcedureName(java.lang.String sql)
           
 int getQueryTimeout()
           
 java.sql.ResultSet getResultSet()
           
 int getResultSetConcurrency()
           
 int getResultSetHoldability()
           
 int getResultSetType()
           
protected  SqlWarning getSqlWarnings()
           
private  java.lang.String getStatementToken(java.lang.String sql)
          Step past any initial non-significant characters and comments to find first significant SQL token so we can classify statement.
 int getUpdateCount()
           
 java.sql.SQLWarning getWarnings()
           
protected  void initResetPreparedStatement()
           
private  void initResetStatement()
           
private  void initStatement()
           
private  void initStatement(Agent agent, Connection connection)
           
private  void initStatement(int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)
           
 boolean isClosed()
          Tell whether the statement has been closed or not.
private  java.lang.String isolateAnyInitialIdentifier(java.lang.String sql)
          Minion of getStatementToken.
 boolean isPoolable()
          Returns the value of the poolable hint, indicating whether pooling is requested.
 boolean isQueryMode()
           
 boolean isWrapperFor(java.lang.Class iface)
          Returns false unless iface is implemented
protected  java.sql.SQLException jdbc3FeatureNotSupported()
           
protected  java.sql.SQLException jdbc3FeatureNotSupported(boolean checkStatement)
           
 void listenToUnitOfWork()
           
(package private)  void mapCursorNameToResultSet()
           
 void markAutoCommitted()
          Mark all ResultSets associated with this statement as auto-committed.
(package private)  void markClosed()
          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.
(package private)  void markClosedOnServer()
           
private  void markPrepared()
           
(package private)  void markPreparedStatementForAutoGeneratedKeysClosed()
           
(package private)  void markResultSetsClosed()
          Mark all ResultSets associated with this statement as closed.
(package private)  void markResultSetsClosed(boolean removeListener)
          Mark all ResultSets associated with this statement as closed.
(package private)  void parseSqlAndSetSqlModes(java.lang.String sql)
           
(package private)  void parseStorProcReturnedScrollableRowset()
           
private  void parseUpdateSql(java.lang.String firstToken)
           
(package private)  void prepareAutoGeneratedKeysStatement()
           
(package private)  void readClose(boolean allowAutoCommits)
           
(package private)  void readCloseResultSets(boolean allowAutoCommits)
           
(package private)  void readCloseResultSets(int number, boolean allowAutoCommits)
           
 void readExecuteCall()
           
 void readExecuteImmediate()
           
 void readExecuteImmediateForBatch(java.lang.String sql)
           
 void readOpenQuery()
           
 void readPrepare()
           
(package private)  void readPrepareAutoGeneratedKeysStatement()
           
 void readPrepareDescribeOutput()
           
 void readSetSpecialRegister()
           
protected  void removeClientCursorNameFromCache()
           
 void reset(boolean fullReset)
           
(package private)  void resetCursorNameAndRemoveFromWhereCurrentOfMappings()
           
(package private)  void resetForReuse()
          Resets the statement for reuse in a statement pool.
private  void resetStatement()
           
 void resetStatement(Agent agent, Connection connection)
           
 void resetStatement(Agent agent, Connection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)
           
private  void resetUserControllableAttributes()
          Resets attributes that can be modified by the user through the Statement interface to default values.
 void resultSetCommitting(ResultSet closingRS)
          Convenience method for resultSetCommitting(ResultSet, boolean)
 boolean resultSetCommitting(ResultSet closingRS, boolean writeChain)
          Method that checks to see if any other ResultSets are open.
 void setCursorName(java.lang.String name)
           
 void setEscapeProcessing(boolean enable)
           
 void setFetchDirection(int direction)
           
 void setFetchSize(int rows)
           
 void setMaxFieldSize(int max)
           
 void setMaxRows(int maxRows)
           
protected  void setOwner(java.sql.Statement owner)
          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 setupCursorNameCacheAndMappings()
           
 void setUpdateCount(int updateCount)
           
protected  java.lang.String substituteClientCursorNameWithServerCursorName(java.lang.String sql, Section section)
           
static java.lang.String upperCaseProcedureName(java.lang.String procedureName)
           
private  boolean willTickleServer(int number, boolean allowAutoCommits)
           
(package private)  void writeClose(boolean allowAutoCommits)
           
(package private)  boolean writeCloseResultSets(boolean allowAutoCommits)
           
(package private)  boolean writeCloseResultSets(int number, boolean allowAutoCommits)
           
 void writeExecuteCall(boolean outputExpected, java.lang.String procedureName, Section section, int fetchSize, boolean suppressResultSets, int resultSetType, ColumnMetaData parameterMetaData, java.lang.Object[] inputs)
           
private  Section writeExecuteCall(java.lang.String sql, boolean isBatch)
           
 void writeExecuteImmediate(java.lang.String sql, Section section)
           
 void writeOpenQuery(Section section, int fetchSize, int resultSetType)
           
 void writePrepare(java.lang.String sql, Section section)
           
 void writePrepareDescribeOutput(java.lang.String sql, Section section)
           
 void writeSetSpecialRegister(java.util.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.Wrapper
unwrap
 

Field Detail

CLOSE_CURRENT_RESULT

public static final int CLOSE_CURRENT_RESULT
See Also:
Constant Field Values

KEEP_CURRENT_RESULT

public static final int KEEP_CURRENT_RESULT
See Also:
Constant Field Values

CLOSE_ALL_RESULTS

public static final int CLOSE_ALL_RESULTS
See Also:
Constant Field Values

materialStatement_

public MaterialStatement materialStatement_

connection_

Connection connection_

section_

public Section section_

agent_

Agent agent_

owner

private java.sql.Statement owner
The owner of this statement, if any.


resultSet_

ResultSet resultSet_

updateCount_

int updateCount_

returnValueFromProcedure_

int returnValueFromProcedure_

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_

isCommitSql__

public static final int isCommitSql__
See Also:
Constant Field Values

isRollbackSql__

public static final int isRollbackSql__
See Also:
Constant Field Values

isPositionedUpdateDeleteSql__

static final int isPositionedUpdateDeleteSql__
See Also:
Constant Field Values

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_

openOnServer_

boolean openOnServer_

indexOfCurrentResultSet_

protected int indexOfCurrentResultSet_

resultSetList_

ResultSet[] resultSetList_

TIMEOUT_STATEMENT

protected static final java.lang.String TIMEOUT_STATEMENT
See Also:
Constant Field Values

timeoutArrayList

protected java.util.ArrayList timeoutArrayList

doWriteTimeout

protected boolean doWriteTimeout

timeout_

int timeout_

maxRows_

int maxRows_

maxFieldSize_

int maxFieldSize_

isAutoCommittableStatement_

boolean isAutoCommittableStatement_

isCatalogQuery_

boolean isCatalogQuery_

batch_

final java.util.ArrayList batch_

resultSetType_

public int resultSetType_

resultSetConcurrency_

public int resultSetConcurrency_

resultSetHoldability_

public int resultSetHoldability_

fetchSize_

public int fetchSize_

fetchDirection_

public int fetchDirection_

singletonRowData_

public Cursor singletonRowData_

numInvisibleRS_

public int numInvisibleRS_

cursorAttributesToSendOnPrepare_

public java.lang.String cursorAttributesToSendOnPrepare_

preparedStatementForAutoGeneratedKeys_

public PreparedStatement preparedStatementForAutoGeneratedKeys_

generatedKeysResultSet_

public ResultSet generatedKeysResultSet_

generatedKeysColumnNames_

public java.lang.String[] generatedKeysColumnNames_

generatedKeysColumnIndexes_

public int[] generatedKeysColumnIndexes_

autoGeneratedKeys_

public int autoGeneratedKeys_

warnings_

private SqlWarning warnings_

isPoolable

protected boolean isPoolable

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.

See Also:
getStatementToken(java.lang.String), Constant Field Values

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

Statement

private Statement()

Statement

public Statement(Agent agent,
                 Connection connection)
          throws SqlException
Throws:
SqlException

Statement

public Statement(Agent agent,
                 Connection connection,
                 int type,
                 int concurrency,
                 int holdability,
                 int autoGeneratedKeys,
                 java.lang.String[] columnNames,
                 int[] columnIndexes)
          throws SqlException
Throws:
SqlException
Method Detail

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 the Statement interface to default values.


reset

public void reset(boolean fullReset)
           throws SqlException
Throws:
SqlException

resetForReuse

void resetForReuse()
             throws SqlException
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:

Throws:
SqlException - if resetting the statement fails

resetStatement

public void resetStatement(Agent agent,
                           Connection connection)
                    throws SqlException
Throws:
SqlException

initStatement

private void initStatement(Agent agent,
                           Connection connection)

resetStatement

public void resetStatement(Agent agent,
                           Connection 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:
finalize in class java.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:
executeQuery in interface java.sql.Statement
Throws:
java.sql.SQLException

executeQueryX

private ResultSet executeQueryX(java.lang.String sql)
                         throws SqlException
Throws:
SqlException

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws java.sql.SQLException
Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException

executeUpdateX

private int executeUpdateX(java.lang.String sql)
                    throws SqlException
Throws:
SqlException

isWrapperFor

public boolean isWrapperFor(java.lang.Class iface)
                     throws java.sql.SQLException
Returns false unless iface is implemented

Specified by:
isWrapperFor in interface java.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.

isClosed

public boolean isClosed()
                 throws java.sql.SQLException
Tell whether the statement has been closed or not.

Specified by:
isClosed in interface java.sql.Statement
Returns:
true if closed, false otherwise.
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:
close in interface java.sql.Statement
Throws:
java.sql.SQLException

closeX

public void closeX()
            throws SqlException
An untraced version of close. 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 between finalize and close 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

public boolean isPoolable()
                   throws java.sql.SQLException
Returns the value of the poolable hint, indicating whether pooling is requested.

Specified by:
isPoolable in interface java.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.SQLException
Requests that a Statement be pooled or not.

Specified by:
setPoolable in interface java.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:
getMaxFieldSize in interface java.sql.Statement
Throws:
java.sql.SQLException

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws java.sql.SQLException
Specified by:
setMaxFieldSize in interface java.sql.Statement
Throws:
java.sql.SQLException

getMaxRows

public int getMaxRows()
               throws java.sql.SQLException
Specified by:
getMaxRows in interface java.sql.Statement
Throws:
java.sql.SQLException

setMaxRows

public void setMaxRows(int maxRows)
                throws java.sql.SQLException
Specified by:
setMaxRows in interface java.sql.Statement
Throws:
java.sql.SQLException

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws java.sql.SQLException
Specified by:
setEscapeProcessing in interface java.sql.Statement
Throws:
java.sql.SQLException

getQueryTimeout

public int getQueryTimeout()
                    throws java.sql.SQLException
Specified by:
getQueryTimeout in interface java.sql.Statement
Throws:
java.sql.SQLException

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws java.sql.SQLException
Specified by:
setQueryTimeout in interface java.sql.Statement
Throws:
java.sql.SQLException

cancel

public void cancel()
            throws java.sql.SQLException
Specified by:
cancel in interface java.sql.Statement
Throws:
java.sql.SQLException

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
Specified by:
getWarnings in interface java.sql.Statement
Throws:
java.sql.SQLException

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Specified by:
clearWarnings in interface java.sql.Statement
Throws:
java.sql.SQLException

clearWarningsX

final void clearWarningsX()

setCursorName

public void setCursorName(java.lang.String name)
                   throws java.sql.SQLException
Specified by:
setCursorName in interface java.sql.Statement
Throws:
java.sql.SQLException

execute

public boolean execute(java.lang.String sql)
                throws java.sql.SQLException
Specified by:
execute in interface java.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:
getResultSet in interface java.sql.Statement
Throws:
java.sql.SQLException

getUpdateCount

public int getUpdateCount()
                   throws java.sql.SQLException
Specified by:
getUpdateCount in interface java.sql.Statement
Throws:
java.sql.SQLException

getMoreResults

public boolean getMoreResults()
                       throws java.sql.SQLException
Specified by:
getMoreResults in interface java.sql.Statement
Throws:
java.sql.SQLException

setFetchDirection

public void setFetchDirection(int direction)
                       throws java.sql.SQLException
Specified by:
setFetchDirection in interface java.sql.Statement
Throws:
java.sql.SQLException

getFetchDirection

public int getFetchDirection()
                      throws java.sql.SQLException
Specified by:
getFetchDirection in interface java.sql.Statement
Throws:
java.sql.SQLException

setFetchSize

public void setFetchSize(int rows)
                  throws java.sql.SQLException
Specified by:
setFetchSize in interface java.sql.Statement
Throws:
java.sql.SQLException

getFetchSize

public int getFetchSize()
                 throws java.sql.SQLException
Specified by:
getFetchSize in interface java.sql.Statement
Throws:
java.sql.SQLException

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws java.sql.SQLException
Specified by:
getResultSetConcurrency in interface java.sql.Statement
Throws:
java.sql.SQLException

getResultSetType

public int getResultSetType()
                     throws java.sql.SQLException
Specified by:
getResultSetType in interface java.sql.Statement
Throws:
java.sql.SQLException

addBatch

public void addBatch(java.lang.String sql)
              throws java.sql.SQLException
Specified by:
addBatch in interface java.sql.Statement
Throws:
java.sql.SQLException

clearBatch

public void clearBatch()
                throws java.sql.SQLException
Specified by:
clearBatch in interface java.sql.Statement
Throws:
java.sql.SQLException

executeBatch

public int[] executeBatch()
                   throws java.sql.SQLException,
                          BatchUpdateException
Specified by:
executeBatch in interface java.sql.Statement
Throws:
java.sql.SQLException
BatchUpdateException

executeBatchX

private int[] executeBatchX()
                     throws SqlException,
                            BatchUpdateException
Throws:
SqlException
BatchUpdateException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Specified by:
getConnection in interface java.sql.Statement
Throws:
java.sql.SQLException

getMoreResults

public boolean getMoreResults(int current)
                       throws java.sql.SQLException
Specified by:
getMoreResults in interface java.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:
getGeneratedKeys in interface java.sql.Statement
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int autoGeneratedKeys)
                  throws java.sql.SQLException
Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int[] columnIndexes)
                  throws java.sql.SQLException
Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate(java.lang.String sql,
                         java.lang.String[] columnNames)
                  throws java.sql.SQLException
Specified by:
executeUpdate in interface java.sql.Statement
Throws:
java.sql.SQLException

execute

public boolean execute(java.lang.String sql,
                       int autoGeneratedKeys)
                throws java.sql.SQLException
Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException

execute

public boolean execute(java.lang.String sql,
                       int[] columnIndexes)
                throws java.sql.SQLException
Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException

execute

public boolean execute(java.lang.String sql,
                       java.lang.String[] columnNames)
                throws java.sql.SQLException
Specified by:
execute in interface java.sql.Statement
Throws:
java.sql.SQLException

getResultSetHoldability

public int getResultSetHoldability()
                            throws java.sql.SQLException
Specified by:
getResultSetHoldability in interface java.sql.Statement
Throws:
java.sql.SQLException

writeSetSpecialRegister

public void writeSetSpecialRegister(java.util.ArrayList sqlsttList)
                             throws SqlException
Throws:
SqlException

readSetSpecialRegister

public void readSetSpecialRegister()
                            throws SqlException
Throws:
SqlException

writeExecuteImmediate

public void writeExecuteImmediate(java.lang.String sql,
                                  Section section)
                           throws SqlException
Throws:
SqlException

readExecuteImmediate

public void readExecuteImmediate()
                          throws SqlException
Throws:
SqlException

completeExecuteImmediate

public void completeExecuteImmediate(Sqlca sqlca)
Specified by:
completeExecuteImmediate in interface StatementCallbackInterface

readExecuteImmediateForBatch

public void readExecuteImmediateForBatch(java.lang.String sql)
                                  throws SqlException
Throws:
SqlException

writePrepareDescribeOutput

public void writePrepareDescribeOutput(java.lang.String sql,
                                       Section section)
                                throws SqlException
Throws:
SqlException

readPrepareDescribeOutput

public void readPrepareDescribeOutput()
                               throws SqlException
Throws:
SqlException

completePrepareDescribeOutput

public void completePrepareDescribeOutput(ColumnMetaData resultSetMetaData,
                                          Sqlca sqlca)
Specified by:
completePrepareDescribeOutput in interface StatementCallbackInterface

writePrepare

public void writePrepare(java.lang.String sql,
                         Section section)
                  throws SqlException
Throws:
SqlException

readPrepare

public void readPrepare()
                 throws SqlException
Throws:
SqlException

completePrepare

public void completePrepare(Sqlca sqlca)
Specified by:
completePrepare in interface StatementCallbackInterface

writeOpenQuery

public void writeOpenQuery(Section section,
                           int fetchSize,
                           int resultSetType)
                    throws SqlException
Throws:
SqlException

readOpenQuery

public void readOpenQuery()
                   throws SqlException
Throws:
SqlException

completeOpenQuery

public void completeOpenQuery(Sqlca sqlca,
                              ResultSet resultSet)
Specified by:
completeOpenQuery in interface StatementCallbackInterface

completeExecuteCallOpenQuery

public void completeExecuteCallOpenQuery(Sqlca sqlca,
                                         ResultSet resultSet,
                                         ColumnMetaData resultSetMetaData,
                                         Section generatedSection)
Specified by:
completeExecuteCallOpenQuery in interface StatementCallbackInterface

writeExecuteCall

public 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

public void readExecuteCall()
                     throws SqlException
Throws:
SqlException

completeExecuteCall

public void completeExecuteCall(Sqlca sqlca,
                                Cursor singletonParams,
                                ResultSet[] resultSets)
Specified by:
completeExecuteCall in interface StatementCallbackInterface

completeExecuteCall

public void completeExecuteCall(Sqlca sqlca,
                                Cursor singletonParams)
Specified by:
completeExecuteCall in interface StatementCallbackInterface

completeExecute

public void completeExecute(Sqlca sqlca)
Specified by:
completeExecute in interface StatementCallbackInterface

setUpdateCount

public void setUpdateCount(int 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 null if 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 SqlException
Throws:
SqlException

writeCloseResultSets

boolean writeCloseResultSets(int number,
                             boolean allowAutoCommits)
                       throws SqlException
Throws:
SqlException

readCloseResultSets

final void readCloseResultSets(boolean allowAutoCommits)
                        throws SqlException
Throws:
SqlException

readCloseResultSets

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:
completeSqlca in interface StatementCallbackInterface

completeExecuteSetStatement

public void completeExecuteSetStatement(Sqlca sqlca)
Specified by:
completeExecuteSetStatement in interface StatementCallbackInterface

markClosedOnServer

void markClosedOnServer()

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 in org.apache.derby.client.am.Connection. This method is called from: 1. finalize() - For the finaizer 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 in org.apache.derby.client.am.Connection.

markPreparedStatementForAutoGeneratedKeysClosed

void markPreparedStatementForAutoGeneratedKeysClosed()

markResultSetsClosed

void markResultSetsClosed()
Mark all ResultSets associated with this statement as closed. The ResultSets will not be removed from the commit and rollback listeners list in org.apache.derby.client.am.Connection.


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 in org.apache.derby.client.am.Connection.

flowExecute

private void flowExecute(int executeType,
                         java.lang.String sql)
                  throws SqlException
Throws:
SqlException

flowExecuteBatch

void flowExecuteBatch(int[] updateCounts)
                throws SqlException,
                       BatchUpdateException
Throws:
SqlException
BatchUpdateException

writeExecuteCall

private Section writeExecuteCall(java.lang.String sql,
                                 boolean isBatch)
                          throws SqlException
Throws:
SqlException

listenToUnitOfWork

public void listenToUnitOfWork()
Specified by:
listenToUnitOfWork in interface UnitOfWorkListener

completeLocalCommit

public void completeLocalCommit(java.util.Iterator listenerIterator)
Specified by:
completeLocalCommit in interface UnitOfWorkListener

completeLocalRollback

public void completeLocalRollback(java.util.Iterator listenerIterator)
Specified by:
completeLocalRollback in interface UnitOfWorkListener

accumulateWarning

public void accumulateWarning(SqlWarning e)
Specified by:
accumulateWarning in interface StatementCallbackInterface

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 SqlException
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

private void parseUpdateSql(java.lang.String firstToken)
                     throws SqlException
Throws:
SqlException

getProcedureName

java.lang.String getProcedureName(java.lang.String sql)
                            throws SqlException
Throws:
SqlException

upperCaseProcedureName

public static java.lang.String upperCaseProcedureName(java.lang.String procedureName)
                                               throws SqlException
Throws:
SqlException

checkForAppropriateSqlMode

final void checkForAppropriateSqlMode(int executeType,
                                      int sqlMode)
                               throws SqlException
Throws:
SqlException

checkResultSetCount

private void checkResultSetCount(int executeType)
                          throws SqlException
Checks that the number of result sets returned by the statement is consistent with the executed type. executeQuery() should return exactly one result set and executeUpdate() none. Raises an exception if the result set count does not match the execute type.

Parameters:
executeType - one of executeQueryMethod__, executeUpdateMethod__ and executeMethod__
Throws:
SqlException - if the number of result sets does not match the execute type

checkForStoredProcResultSetCount

protected final void checkForStoredProcResultSetCount(int executeType)
                                               throws SqlException
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 of executeQueryMethod__, executeUpdateMethod__ and executeMethod__
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

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:
getConnectionCallbackInterface in interface StatementCallbackInterface

resetCursorNameAndRemoveFromWhereCurrentOfMappings

void resetCursorNameAndRemoveFromWhereCurrentOfMappings()

mapCursorNameToResultSet

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

getPreparedStatementForAutoGeneratedKeys

void getPreparedStatementForAutoGeneratedKeys()
                                        throws SqlException
Throws:
SqlException

prepareAutoGeneratedKeysStatement

void prepareAutoGeneratedKeysStatement()
                                 throws SqlException
Throws:
SqlException

readPrepareAutoGeneratedKeysStatement

void readPrepareAutoGeneratedKeysStatement()
                                     throws SqlException
Throws:
SqlException

checkAutoGeneratedKeysParameters

void checkAutoGeneratedKeysParameters()
                                throws SqlException
Throws:
SqlException

getGuessedResultSetMetaData

public ColumnMetaData getGuessedResultSetMetaData()
Specified by:
getGuessedResultSetMetaData in interface StatementCallbackInterface

isQueryMode

public boolean isQueryMode()

removeClientCursorNameFromCache

protected void removeClientCursorNameFromCache()

resultSetCommitting

public void resultSetCommitting(ResultSet closingRS)
                         throws SqlException
Convenience method for resultSetCommitting(ResultSet, boolean)

Parameters:
closingRS - The ResultSet to be closed
Throws:
SqlException
See Also:
resultSetCommitting(ResultSet, boolean)

resultSetCommitting

public boolean resultSetCommitting(ResultSet 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 closed
writeChain - A Boolean indicating whether this method is part of a chain of write from client to Server
Throws:
SqlException

markAutoCommitted

public void markAutoCommitted()
Mark all ResultSets associated with this statement as auto-committed.


jdbc3FeatureNotSupported

protected java.sql.SQLException jdbc3FeatureNotSupported(boolean checkStatement)
                                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

jdbc3FeatureNotSupported

protected java.sql.SQLException jdbc3FeatureNotSupported()
                                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.