Top Fields Constructors Methods
org.apache.derby.client.am

public Class ClientStatement

extends Object
implements Statement, StatementCallbackInterface
Class Inheritance
All Implemented Interfaces
org.apache.derby.client.am.StatementCallbackInterface, org.apache.derby.client.am.UnitOfWorkListener, java.sql.Statement, java.lang.AutoCloseable, java.sql.Wrapper
Known Direct Subclasses
org.apache.derby.client.am.ClientPreparedStatement
Imports
java.sql.BatchUpdateException, .Connection, .ResultSet, .SQLException, .SQLWarning, .Statement, java.util.ArrayList, .Arrays, .Iterator, .StringTokenizer, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.shared.common.sanity.SanityManager

Field Summary

Modifier and TypeField and Description
pack-priv Agent
pack-priv int
pack-priv final ArrayList<Object>
public Cursor
public Cursor
private boolean
private boolean
pack-priv ClientConnection
public String
pack-priv String
protected boolean
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv int
private static long
fetchedRowBase

For use in debugging setLargeMaxRows() method added by JDBC 4.2

pack-priv int
pack-priv int[]
pack-priv String[]
pack-priv ClientResultSet
private int
private static final int
private static final int
pack-priv boolean
pack-priv static final int
pack-priv boolean
pack-priv static final int
pack-priv static final int
protected boolean
pack-priv boolean
pack-priv static final int
pack-priv static final int
pack-priv static final int
private MaterialStatement
pack-priv int
pack-priv long
pack-priv boolean
private static final int
OUTSIDE

State constants used by the FSM inside getStatementToken.

private Statement
owner

The owner of this statement, if any.

pack-priv ClientPreparedStatement
pack-priv ClientResultSet
public int
pack-priv int
pack-priv ClientResultSet[]
pack-priv ColumnMetaData
public int
private Section
private Section
setSpecialRegisterSection_

This variable keeps track of a Section dediacted to writeSpecialRegister.

pack-priv Cursor
protected int
pack-priv int
pack-priv int
protected static final String
protected ArrayList<String>
pack-priv long
private SqlWarning

Constructor Summary

AccessConstructor and Description
private
public
public
ClientStatement(Agent agent, ClientConnection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes)

Method Summary

Modifier and TypeMethod and Description
public void
public void
addBatch(String
typically this is a SQL INSERT or UPDATE statement
sql
)

Implements java.sql.Statement.addBatch.

Adds the given SQL command to the current list of commands for this Statement object.
pack-priv String
public void
cancel()

Implements java.sql.Statement.cancel.

Cancels this Statement object if both the DBMS and driver support aborting an SQL statement.
pack-priv void
pack-priv final void
checkForAppropriateSqlMode(int executeType, int sqlMode)

pack-priv final void
protected void
private void
protected final void
checkForStoredProcResultSetCount(int
one of executeQueryMethod__, executeUpdateMethod__ and executeMethod__
executeType
)

Checks that a stored procedure returns the correct number of result sets given its execute type.

private void
checkResultSetCount(int
one of executeQueryMethod__, executeUpdateMethod__ and executeMethod__
executeType
)

Checks that the number of result sets returned by the statement is consistent with the executed type.

public void
clearBatch()

Implements java.sql.Statement.clearBatch.

Empties this Statement object's current list of SQL commands.
public void
clearWarnings()

Implements java.sql.Statement.clearWarnings.

Clears all the warnings reported on this Statement object.
pack-priv final void
public void
close()

Implements java.sql.Statement.close.

Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
private void
closeEverythingExceptResultSets(boolean removeListener)

Close all resources except for ResultSets.

pack-priv void
public void
closeOnCompletion()

Implements java.sql.Statement.closeOnCompletion.

Specifies that this Statement will be closed when all its dependent result sets are closed.
pack-priv void
closeX()

An untraced version of close.

public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public int
pack-priv String
public boolean
execute(String
any SQL statement
sql
)

Implements java.sql.Statement.execute.

Executes the given SQL statement, which may return multiple results.
public boolean
execute(String
any SQL statement
sql
,
int
a constant indicating whether auto-generated keys should be made available for retrieval using the method getGeneratedKeys; one of the following constants: Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS
autoGeneratedKeys
)

Implements java.sql.Statement.execute.

Executes the given SQL statement, which may return multiple results, and signals the driver that any auto-generated keys should be made available for retrieval.
public boolean
execute(String
any SQL statement
sql
,
int[]
an array of the indexes of the columns in the inserted row that should be made available for retrieval by a call to the method getGeneratedKeys
columnIndexes
)

Implements java.sql.Statement.execute.

Executes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
public boolean
execute(String
any SQL statement
sql
,
String[]
an array of the names of the columns in the inserted row that should be made available for retrieval by a call to the method getGeneratedKeys
columnNames
)

Implements java.sql.Statement.execute.

Executes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
public int[]
executeBatch()

Implements java.sql.Statement.executeBatch.

Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.
private long[]
public long[]
executeLargeBatch()

Overrides default java.sql.Statement.executeLargeBatch.

Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.
public long
executeLargeUpdate(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
)

Overrides default java.sql.Statement.executeLargeUpdate.

Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.
public long
executeLargeUpdate(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
int
a flag indicating whether auto-generated keys should be made available for retrieval; one of the following constants: Statement.RETURN_GENERATED_KEYS Statement.NO_GENERATED_KEYS
autoGeneratedKeys
)

Overrides default java.sql.Statement.executeLargeUpdate.

Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement object should be made available for retrieval.
public long
executeLargeUpdate(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
int[]
an array of column indexes indicating the columns that should be returned from the inserted row
columnIndexes
)

Overrides default java.sql.Statement.executeLargeUpdate.

Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
public long
executeLargeUpdate(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
String[]
an array of the names of the columns that should be returned from the inserted row
columnNames
)

Overrides default java.sql.Statement.executeLargeUpdate.

Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
public ResultSet
executeQuery(String
an SQL statement to be sent to the database, typically a static SQL SELECT statement
sql
)

Implements java.sql.Statement.executeQuery.

Executes the given SQL statement, which returns a single ResultSet object.
private ClientResultSet
public int
executeUpdate(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
)

Implements java.sql.Statement.executeUpdate.

Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.
public int
executeUpdate(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
int
a flag indicating whether auto-generated keys should be made available for retrieval; one of the following constants: Statement.RETURN_GENERATED_KEYS Statement.NO_GENERATED_KEYS
autoGeneratedKeys
)

Implements java.sql.Statement.executeUpdate.

Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement object should be made available for retrieval.
public int
executeUpdate(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
int[]
an array of column indexes indicating the columns that should be returned from the inserted row
columnIndexes
)

Implements java.sql.Statement.executeUpdate.

Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
public int
executeUpdate(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
,
String[]
an array of the names of the columns that should be returned from the inserted row
columnNames
)

Implements java.sql.Statement.executeUpdate.

Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
private long
pack-priv boolean
pack-priv String[]
protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
private void
private void
private void
private void
private void
flowExecute(int executeType, String sql)

private void
flowExecuteBatch(long[] updateCounts)

public Connection
getConnection()

Implements java.sql.Statement.getConnection.

Retrieves the Connection object that produced this Statement object.
public ConnectionCallbackInterface
public int
getFetchDirection()

Implements java.sql.Statement.getFetchDirection.

Retrieves the direction for fetching rows from database tables that is the default for result sets generated from this Statement object.
public int
getFetchSize()

Implements java.sql.Statement.getFetchSize.

Retrieves the number of result set rows that is the default fetch size for ResultSet objects generated from this Statement object.
public ResultSet
getGeneratedKeys()

Implements java.sql.Statement.getGeneratedKeys.

Retrieves any auto-generated keys created as a result of executing this Statement object.
public ColumnMetaData
protected String

Returns:

name of java.sql interface
getJdbcStatementInterfaceName
()

Returns the name of the java.sql interface implemented by this class.

public long
getLargeMaxRows()

Overrides default java.sql.Statement.getLargeMaxRows.

Retrieves the maximum number of rows that a ResultSet object produced by this Statement object can contain.
public long
getLargeUpdateCount()

Overrides default java.sql.Statement.getLargeUpdateCount.

Retrieves the current result as an update count; if the result is a ResultSet object or there are no more results, -1 is returned.
public MaterialStatement

Returns:

the materialStatement
getMaterialStatement
()

public int
getMaxFieldSize()

Implements java.sql.Statement.getMaxFieldSize.

Retrieves the maximum number of bytes that can be returned for character and binary column values in a ResultSet object produced by this Statement object.
public int
getMaxRows()

Implements java.sql.Statement.getMaxRows.

Retrieves the maximum number of rows that a ResultSet object produced by this Statement object can contain.
public boolean
getMoreResults()

Implements java.sql.Statement.getMoreResults.

Moves to this Statement object's next result, returns true if it is a ResultSet object, and implicitly closes any current ResultSet object(s) obtained with the method getResultSet.
public boolean
getMoreResults(int
one of the following Statement constants indicating what should happen to current ResultSet objects obtained using the method getResultSet: Statement.CLOSE_CURRENT_RESULT, Statement.KEEP_CURRENT_RESULT, or Statement.CLOSE_ALL_RESULTS
current
)

Implements java.sql.Statement.getMoreResults.

Moves to this Statement object's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object.
private boolean
getMoreResultsX(int current)

pack-priv final Statement

Returns:

The designated owner of this statement, or null if none.
getOwner
()

Returns the owner of this statement, if any.

public int
getQueryTimeout()

Implements java.sql.Statement.getQueryTimeout.

Retrieves the number of seconds the driver will wait for a Statement object to execute.
public ResultSet
getResultSet()

Implements java.sql.Statement.getResultSet.

Retrieves the current result as a ResultSet object.
public int
getResultSetConcurrency()

Implements java.sql.Statement.getResultSetConcurrency.

Retrieves the result set concurrency for ResultSet objects generated by this Statement object.
public int
getResultSetHoldability()

Implements java.sql.Statement.getResultSetHoldability.

Retrieves the result set holdability for ResultSet objects generated by this Statement object.
public int
getResultSetType()

Implements java.sql.Statement.getResultSetType.

Retrieves the result set type for ResultSet objects generated by this Statement object.
public Section

Returns:

section_
getSection
()

Provides public access for section_.

protected SqlWarning
private String

Returns:

first significant SQL token
getStatementToken
(String sql)

Step past any initial non-significant characters and comments to find first significant SQL token so we can classify statement.

public int
getUpdateCount()

Implements java.sql.Statement.getUpdateCount.

Retrieves the current result as an update count; if the result is a ResultSet object or there are no more results, -1 is returned.
public SQLWarning
getWarnings()

Implements java.sql.Statement.getWarnings.

Retrieves the first warning reported by calls on this Statement object.
protected void
private void
private void
private void
private void
initStatement(int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes)

public boolean

Returns:

true if closed, false otherwise.
isClosed
()

Implements java.sql.Statement.isClosed.

Tell whether the statement has been closed or not.
public boolean
isCloseOnCompletion()

Implements java.sql.Statement.isCloseOnCompletion.

Returns a value indicating whether this Statement will be closed when all its dependent result sets are closed.
private String

Returns:

identifier or unmodified string
isolateAnyInitialIdentifier
(String
input string
sql
)

Minion of getStatementToken.

private boolean
public boolean

Returns:

The value of the poolable hint.
isPoolable
()

Implements java.sql.Statement.isPoolable.

Returns the value of the poolable hint, indicating whether pooling is requested.
public boolean
public boolean

Returns:

true if this implements the interface or directly or indirectly wraps an object that does.
isWrapperFor
(Class<?>
a Class defining an interface.
iface
)

Implements java.sql.Wrapper.isWrapperFor.

Returns false unless iface is implemented
public void
private void
private void
markAutoCommitted()

Mark all ResultSets associated with this statement as auto-committed.

pack-priv void
markClosed()

This method cleans up client-side resources held by this Statement.

pack-priv void
markClosed(boolean
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.
removeListener
)

This method cleans up client-side resources held by this Statement.

private void
private void
pack-priv final void
markResultSetsClosed(boolean
if true the ResultSets will be removed from the commit and rollback listeners list in org.apache.derby.client.am.Connection.
removeListener
)

Mark all ResultSets associated with this statement as closed.

pack-priv void
pack-priv void
private void
parseUpdateSql(String firstToken)

protected static ClientPreparedStatement
pack-priv final void
readClose(boolean allowAutoCommits)

pack-priv final void
readCloseResultSets(boolean allowAutoCommits)

private void
readCloseResultSets(int number, boolean allowAutoCommits)

pack-priv void
private void
private void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
protected void
public void
reset(boolean fullReset)

pack-priv void
pack-priv void
resetForReuse()

Resets the statement for reuse in a statement pool.

pack-priv void
private void
pack-priv void
public void
resetStatement(Agent agent, ClientConnection connection, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes)

private void
resetUserControllableAttributes()

Resets attributes that can be modified by the user through the java.sql.Statement interface to default values.

pack-priv void
resultSetCommitting(ClientResultSet
The ResultSet to be closed
closingRS
)

Convenience method for resultSetCommitting(ClientResultSet, boolean)

pack-priv boolean
resultSetCommitting(ClientResultSet
The ResultSet to be closed
closingRS
,
boolean
A Boolean indicating whether this method is part of a chain of write from client to Server
writeChain
)

Method that checks to see if any other ResultSets are open.

public void
setCursorName(String
the new cursor name, which must be unique within a connection
name
)

Implements java.sql.Statement.setCursorName.

Sets the SQL cursor name to the given String, which will be used by subsequent Statement object execute methods.
public void
setEscapeProcessing(boolean
true to enable escape processing; false to disable it
enable
)

Implements java.sql.Statement.setEscapeProcessing.

Sets escape processing on or off.
public void
setFetchDirection(int
the initial direction for processing rows
direction
)

Implements java.sql.Statement.setFetchDirection.

Gives the driver a hint as to the direction in which rows will be processed in ResultSet objects created using this Statement object.
public static void
setFetchedRowBase(long
Base value to add to row count for debug purposes
newBase
)

Debug method used to test the setLargeMaxRows() method added by JDBC 4.2.

public void
setFetchSize(int
the number of rows to fetch
rows
)

Implements java.sql.Statement.setFetchSize.

Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for ResultSet objects generated by this Statement.
public void
setLargeMaxRows(long
the new max rows limit; zero means there is no limit
maxRows
)

Overrides default java.sql.Statement.setLargeMaxRows.

Sets the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the given number.
public void
setMaterialStatement(MaterialStatement
the materialStatement to set
materialStatement
)

public void
setMaxFieldSize(int
the new column size limit in bytes; zero means there is no limit
max
)

Implements java.sql.Statement.setMaxFieldSize.

Sets the limit for the maximum number of bytes that can be returned for character and binary column values in a ResultSet object produced by this Statement object.
public void
setMaxRows(int
the new max rows limit; zero means there is no limit
maxRows
)

Implements java.sql.Statement.setMaxRows.

Sets the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the given number.
protected final void
setOwner(Statement
the owning statement, if any
owner
)

Designates the owner of this statement, typically a logical statement.

public void
setPoolable(boolean
requests that the Statement be pooled if true and not be pooled if false.
poolable
)

Implements java.sql.Statement.setPoolable.

Requests that a Statement be pooled or not.
public void
setQueryTimeout(int
the new query timeout limit in seconds; zero means there is no limit
seconds
)

Implements java.sql.Statement.setQueryTimeout.

Sets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds.
protected void
setSection(Section
the section_ to set.
s
)

Assigns a new value (even null) to section_.

protected void
public void
setUpdateCount(long updateCount)

protected String
public <T> T

Returns:

an object that implements the interface
unwrap
(Class<T>
a class defining an interface
iface
)

Implements java.sql.Wrapper.unwrap.

Returns this if this class implements the specified interface.
private boolean
willTickleServer(int number, boolean allowAutoCommits)

pack-priv final void
writeClose(boolean allowAutoCommits)

pack-priv final boolean
writeCloseResultSets(boolean allowAutoCommits)

The connection close processing passes allowAutoCommits=false because if we drove an auto-commits after each statement close, then when we issue close requests on non-held cursors the server would complain that the non-held cursor was already closed from the previous statement's auto-commit.

private boolean
writeCloseResultSets(int number, boolean allowAutoCommits)

pack-priv void
writeExecuteCall(boolean outputExpected, String procedureName, Section section, int fetchSize, boolean suppressResultSets, int resultSetType, ColumnMetaData parameterMetaData, Object[] inputs)

private Section
writeExecuteCall(String sql, boolean isBatch)

private void
pack-priv void
writeOpenQuery(Section section, int fetchSize, int resultSetType)

pack-priv void
writePrepare(String sql, Section section)

pack-priv void
pack-priv void
Inherited from java.lang.Object:
cloneequalsgetClasshashCodenotifynotifyAlltoStringwaitwaitwait