Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.client.am
Class Statement  view Statement download Statement.java

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

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


Field Summary
 Agent agent_
           
 int autoGeneratedKeys_
           
(package private)  java.util.ArrayList batch_
           
 Cursor cachedCursor_
           
 Cursor cachedSingletonRowData_
           
static int CLOSE_ALL_RESULTS
           
static int CLOSE_CURRENT_RESULT
           
 Connection connection_
           
 java.lang.String cursorAttributesToSendOnPrepare_
           
(package private)  java.lang.String cursorName_
           
 DatabaseMetaData databaseMetaData_
           
(package private)  boolean escapedProcedureCallWithResult_
           
(package private) static int executeMethod__
           
(package private) static int executeQueryMethod__
           
(package private) static int executeUpdateMethod__
           
 int fetchDirection_
           
 int fetchSize_
           
 java.lang.String[] generatedKeysColumnNames_
           
 ResultSet generatedKeysResultSet_
           
protected  int indexOfCurrentResultSet_
           
 boolean isAutoCommittableStatement_
           
(package private) static int isCall__
           
 boolean isCallableStatement_
           
(package private)  boolean isCatalogQuery_
           
static int isCommitSql__
           
(package private) static int isDeleteSql__
           
(package private) static int isInsertSql__
           
(package private) static int isPositionedUpdateDeleteSql__
           
 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_
           
 PreparedStatement preparedStatementForAutoGeneratedKeys_
           
 ResultSet resultSet_
           
 int resultSetConcurrency_
           
 int resultSetHoldability_
           
(package private)  ResultSet[] resultSetList_
           
 ColumnMetaData resultSetMetaData_
           
 int resultSetType_
           
(package private)  int returnValueFromProcedure_
           
 Section section_
           
 Cursor singletonRowData_
           
protected  int sqlMode_
           
 int sqlUpdateMode_
           
(package private)  int timeout_
           
(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)
           
 
Method Summary
 void accumulateWarning(SqlWarning e)
           
 void addBatch(java.lang.String sql)
          This method adds a SQL statement to a SQL batch.
(package private)  java.lang.String cacheCursorAttributesToSendOnPrepare()
           
 void cancel()
          This method cancels an outstanding statement, if the database supports that operation.
(package private)  void checkAutoGeneratedKeysParameters()
           
(package private)  void checkExecuteQueryPostConditions(java.lang.String jdbcStatementInterfaceName)
           
(package private)  void checkExecuteUpdatePostConditions(java.lang.String jdbcStatementInterfaceName)
           
(package private)  void checkForAppropriateSqlMode(int executeType, int sqlMode)
           
(package private)  void checkForClosedStatement()
           
(package private)  void checkForInvalidBatchedSql(java.lang.String sql)
           
 void clearBatch()
          This method clears out any SQL statements that have been populated in the current batch.
 void clearWarnings()
          This method clears any SQL warnings that have been attached to this statement.
 void clearWarningsX()
           
 void close()
          This method closes the statement and frees any associated resources.
 void closeX()
           
 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)
           
protected  java.lang.String constructSelectFromInsertSQL(java.lang.String sql)
           
(package private)  java.lang.String escape(java.lang.String sql)
           
 boolean execute(java.lang.String sql)
          This method executes an arbitrary SQL statement of any time.
 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()
          This method executes the SQL batch and returns an array of update counts - one for each SQL statement in the batch - ordered in the same order the statements were added to the batch.
private  int[] executeBatchX()
           
 java.sql.ResultSet executeQuery(java.lang.String sql)
          This method executes the specified SQL SELECT statement and returns a (possibly empty) ResultSet with the results of the query.
private  ResultSet executeQueryX(java.lang.String sql)
           
 int executeUpdate(java.lang.String sql)
          This method executes the specified SQL INSERT, UPDATE, or DELETE statement and returns the number of rows affected, which may be 0.
 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()
          Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed.
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()
          This method returns the Connection instance that was used to create this object.
 ConnectionCallbackInterface getConnectionCallbackInterface()
           
 int getFetchDirection()
          This method returns the current direction that the driver thinks the result set will be accessed int.
 int getFetchSize()
          This method returns the number of rows the driver believes should be fetched from the database at a time.
 java.sql.ResultSet getGeneratedKeys()
           
 ColumnMetaData getGuessedResultSetMetaData()
           
 int getMaxFieldSize()
          This method returns the maximum length of any column value in bytes.
 int getMaxRows()
          This method returns the maximum possible number of rows in a result set.
 boolean getMoreResults()
          This method advances the result set pointer to the next result set, which can then be retrieved using getResultSet
 boolean getMoreResults(int current)
           
private  boolean getMoreResultsX(int current)
           
(package private)  void getPreparedStatementForAutoGeneratedKeys()
           
(package private)  java.lang.String getProcedureName(java.lang.String sql)
           
 int getQueryTimeout()
          The method returns the number of seconds a statement may be in process before timing out.
 java.sql.ResultSet getResultSet()
          This method returns the result set of the SQL statement that was executed.
 int getResultSetConcurrency()
          This method returns the concurrency type of the result set for this statement.
 int getResultSetHoldability()
           
 int getResultSetType()
          This method returns the result set type for this statement.
 int getUpdateCount()
          This method returns the update count of the SQL statement that was executed.
 java.sql.SQLWarning getWarnings()
          This method returns the first SQL warning attached to this statement.
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)
           
 boolean isQueryMode()
           
 void listenToUnitOfWork()
           
(package private)  void mapCursorNameToResultSet()
           
(package private)  void markClosed()
           
(package private)  void markClosedOnServer()
           
private  void markPrepared()
           
(package private)  void markPreparedStatementForAutoGeneratedKeysClosed()
           
(package private)  void markResultSetsClosed()
           
(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()
           
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)
           
 void setCursorName(java.lang.String name)
          This method sets the cursor name that will be used by the result set.
 void setEscapeProcessing(boolean enable)
          This method sets the local escape processing mode on or off.
 void setFetchDirection(int direction)
          This method informs the driver which direction the result set will be accessed in.
 void setFetchSize(int rows)
          This method informs the driver how many rows it should fetch from the database at a time.
 void setMaxFieldSize(int max)
          This method sets the limit for the maximum length of any column in bytes.
 void setMaxRows(int maxRows)
          This method sets the maximum number of rows that can be present in a result set.
 void setQueryTimeout(int seconds)
          This method sets the number of seconds a statement may be in process before timing out.
 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
 

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_

public Connection connection_

warnings_

private SqlWarning warnings_

section_

public Section section_

agent_

public Agent agent_

resultSet_

public 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_

public 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_

public ColumnMetaData resultSetMetaData_

cachedCursor_

public Cursor cachedCursor_

cachedSingletonRowData_

public Cursor cachedSingletonRowData_

isPreparedStatement_

public boolean isPreparedStatement_

isCallableStatement_

public boolean isCallableStatement_

databaseMetaData_

public DatabaseMetaData databaseMetaData_

cursorName_

java.lang.String cursorName_

openOnClient_

boolean openOnClient_

openOnServer_

boolean openOnServer_

indexOfCurrentResultSet_

protected int indexOfCurrentResultSet_

resultSetList_

ResultSet[] resultSetList_

timeout_

int timeout_

maxRows_

int maxRows_

maxFieldSize_

int maxFieldSize_

escapedProcedureCallWithResult_

boolean escapedProcedureCallWithResult_

isAutoCommittableStatement_

public boolean isAutoCommittableStatement_

isCatalogQuery_

boolean isCatalogQuery_

batch_

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_

autoGeneratedKeys_

public int autoGeneratedKeys_
Constructor Detail

Statement

private Statement()
           throws SqlException

Statement

public Statement(Agent agent,
                 Connection connection)
          throws SqlException

Statement

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

resetStatement

private void resetStatement()
                     throws SqlException

initStatement

private void initStatement()
                    throws SqlException

initResetStatement

private void initResetStatement()
                         throws SqlException

initResetPreparedStatement

protected void initResetPreparedStatement()

reset

public void reset(boolean fullReset)
           throws SqlException

resetStatement

public void resetStatement(Agent agent,
                           Connection connection)
                    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)
                    throws SqlException

initStatement

private void initStatement(int type,
                           int concurrency,
                           int holdability,
                           int autoGeneratedKeys,
                           java.lang.String[] columnNames)
                    throws SqlException

finalize

protected void finalize()
                 throws java.lang.Throwable
Description copied from class: java.lang.Object
Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed. You would think that this means it eventually is called on every Object, but this is not necessarily the case. If execution terminates abnormally, garbage collection does not always happen. Thus you cannot rely on this method to always work. For finer control over garbage collection, use references from the java.lang.ref package.

Virtual Machines are free to not call this method if they can determine that it does nothing important; for example, if your class extends Object and overrides finalize to do simply super.finalize().

finalize() will be called by a java.lang.Thread that has no locks on any Objects, and may be called concurrently. There are no guarantees on the order in which multiple objects are finalized. This means that finalize() is usually unsuited for performing actions that must be thread-safe, and that your implementation must be use defensive programming if it is to always work.

If an Exception is thrown from finalize() during garbage collection, it will be patently ignored and the Object will still be destroyed.

It is allowed, although not typical, for user code to call finalize() directly. User invocation does not affect whether automatic invocation will occur. It is also permitted, although not recommended, for a finalize() method to "revive" an object by making it reachable from normal code again.

Unlike constructors, finalize() does not get called for an object's superclass unless the implementation specifically calls super.finalize().

The default implementation does nothing.


executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sql)
                                throws SqlException
Description copied from interface: java.sql.Statement
This method executes the specified SQL SELECT statement and returns a (possibly empty) ResultSet with the results of the query.

Specified by:
executeQuery in interface java.sql.Statement

executeQueryX

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

checkExecuteQueryPostConditions

void checkExecuteQueryPostConditions(java.lang.String jdbcStatementInterfaceName)
                               throws SqlException

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws SqlException
Description copied from interface: java.sql.Statement
This method executes the specified SQL INSERT, UPDATE, or DELETE statement and returns the number of rows affected, which may be 0.

Specified by:
executeUpdate in interface java.sql.Statement

executeUpdateX

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

checkExecuteUpdatePostConditions

void checkExecuteUpdatePostConditions(java.lang.String jdbcStatementInterfaceName)
                                throws SqlException

close

public void close()
           throws SqlException
Description copied from interface: java.sql.Statement
This method closes the statement and frees any associated resources.

Specified by:
close in interface java.sql.Statement

closeX

public void closeX()
            throws SqlException

getMaxFieldSize

public int getMaxFieldSize()
                    throws SqlException
Description copied from interface: java.sql.Statement
This method returns the maximum length of any column value in bytes.

Specified by:
getMaxFieldSize in interface java.sql.Statement

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws SqlException
Description copied from interface: java.sql.Statement
This method sets the limit for the maximum length of any column in bytes.

Specified by:
setMaxFieldSize in interface java.sql.Statement

getMaxRows

public int getMaxRows()
               throws SqlException
Description copied from interface: java.sql.Statement
This method returns the maximum possible number of rows in a result set.

Specified by:
getMaxRows in interface java.sql.Statement

setMaxRows

public void setMaxRows(int maxRows)
                throws SqlException
Description copied from interface: java.sql.Statement
This method sets the maximum number of rows that can be present in a result set.

Specified by:
setMaxRows in interface java.sql.Statement

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws SqlException
Description copied from interface: java.sql.Statement
This method sets the local escape processing mode on or off. The default value is on.

Specified by:
setEscapeProcessing in interface java.sql.Statement

getQueryTimeout

public int getQueryTimeout()
                    throws SqlException
Description copied from interface: java.sql.Statement
The method returns the number of seconds a statement may be in process before timing out. A value of 0 means there is no timeout.

Specified by:
getQueryTimeout in interface java.sql.Statement

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws SqlException
Description copied from interface: java.sql.Statement
This method sets the number of seconds a statement may be in process before timing out. A value of 0 means there is no timeout.

Specified by:
setQueryTimeout in interface java.sql.Statement

cancel

public void cancel()
            throws SqlException
Description copied from interface: java.sql.Statement
This method cancels an outstanding statement, if the database supports that operation.

Specified by:
cancel in interface java.sql.Statement

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws SqlException
Description copied from interface: java.sql.Statement
This method returns the first SQL warning attached to this statement. Subsequent warnings will be chained to this one.

Specified by:
getWarnings in interface java.sql.Statement

clearWarnings

public void clearWarnings()
                   throws SqlException
Description copied from interface: java.sql.Statement
This method clears any SQL warnings that have been attached to this statement.

Specified by:
clearWarnings in interface java.sql.Statement

clearWarningsX

public void clearWarningsX()

setCursorName

public void setCursorName(java.lang.String name)
                   throws SqlException
Description copied from interface: java.sql.Statement
This method sets the cursor name that will be used by the result set.

Specified by:
setCursorName in interface java.sql.Statement

execute

public boolean execute(java.lang.String sql)
                throws SqlException
Description copied from interface: java.sql.Statement
This method executes an arbitrary SQL statement of any time. The methods getResultSet, getMoreResults and getUpdateCount retrieve the results.

Specified by:
execute in interface java.sql.Statement

executeX

boolean executeX(java.lang.String sql)
           throws SqlException

getResultSet

public java.sql.ResultSet getResultSet()
                                throws SqlException
Description copied from interface: java.sql.Statement
This method returns the result set of the SQL statement that was executed. This should be called only once per result set returned.

Specified by:
getResultSet in interface java.sql.Statement

getUpdateCount

public int getUpdateCount()
                   throws SqlException
Description copied from interface: java.sql.Statement
This method returns the update count of the SQL statement that was executed. This should be called only once per executed SQL statement.

Specified by:
getUpdateCount in interface java.sql.Statement

getMoreResults

public boolean getMoreResults()
                       throws SqlException
Description copied from interface: java.sql.Statement
This method advances the result set pointer to the next result set, which can then be retrieved using getResultSet

Specified by:
getMoreResults in interface java.sql.Statement

setFetchDirection

public void setFetchDirection(int direction)
                       throws SqlException
Description copied from interface: java.sql.Statement
This method informs the driver which direction the result set will be accessed in.