abstract class LogicalStatementEntity
extends java.lang.Object
implements java.sql.Statement
Note that getPhysPs()
and getPhysCs()
takes care of checking if
the logical statement has been closed. The physical statement will take care
of validating itself.
Beside from the above, special treatment of logical entities happens on close. This is the point where cache interaction takes place, and also where the appropriate methods are called on the physical statement to perform the necessary clean up for later reuse.
A note regarding the thread safety of this class, is that access to
physicalPs
and physicalCs
is guarded by the instance of this
class, but it is assumed that operation on/within the physical statement is
synchronized in the physical statement itself .
Modifier and Type | Field and Description |
---|---|
private JDBCStatementCache |
cache
Cache for physical statements.
|
private boolean |
hasCallableStmt
Tells if we're holding a callable statement or not.
|
private StatementCacheInteractor |
owner
The owner of this logical entity.
|
private java.sql.CallableStatement |
physicalCs
Associated physical callable statement, if any.
|
private java.sql.PreparedStatement |
physicalPs
Associated physical prepared statement.
|
private StatementKey |
stmtKey
The key for the associated statement.
|
Modifier | Constructor and Description |
---|---|
protected |
LogicalStatementEntity(java.sql.PreparedStatement physicalPs,
StatementKey stmtKey,
StatementCacheInteractor cacheInteractor)
Create a logical entity for a
PreparedStatement . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the logical statement.
|
void |
closeOnCompletion() |
long[] |
executeLargeBatch() |
long |
executeLargeUpdate(java.lang.String sql) |
long |
executeLargeUpdate(java.lang.String sql,
int autoGeneratedKeys) |
long |
executeLargeUpdate(java.lang.String sql,
int[] columnIndexes) |
long |
executeLargeUpdate(java.lang.String sql,
java.lang.String[] columnNames) |
long |
getLargeMaxRows() |
long |
getLargeUpdateCount() |
(package private) java.sql.CallableStatement |
getPhysCs()
Returns the associated physical callable statement.
|
(package private) java.sql.PreparedStatement |
getPhysPs()
Returns the associated physical prepared statement.
|
private java.sql.Statement |
getPhysStmt()
Returns the associated physical statement.
|
boolean |
isCloseOnCompletion() |
(package private) boolean |
isLogicalEntityClosed()
Tells if the logical entity is closed.
|
boolean |
isWrapperFor(java.lang.Class<?> iface)
Check whether this instance wraps an object that implements the interface
specified by
iface . |
void |
setLargeMaxRows(long maxRows) |
<T> T |
unwrap(java.lang.Class<T> iface)
Returns an instance of the specified interface if this instance is
a wrapper for the interface.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addBatch, cancel, clearBatch, clearWarnings, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isPoolable, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
private final boolean hasCallableStmt
Used for sanity checking.
private java.sql.PreparedStatement physicalPs
If this is null
, the logical entity is closed.
private java.sql.CallableStatement physicalCs
This is a convenience reference, to avoid having to cast on every
invocation of getPhysCs()
if the logical entity represents a
callable statement.
private StatementCacheInteractor owner
private final StatementKey stmtKey
private final JDBCStatementCache cache
protected LogicalStatementEntity(java.sql.PreparedStatement physicalPs, StatementKey stmtKey, StatementCacheInteractor cacheInteractor)
PreparedStatement
.physicalPs
- a physical PreparedStatement
stmtKey
- cache key for the physical statementcacheInteractor
- creating statement cache interactorjava.lang.IllegalArgumentException
- if cache
is null
java.sql.PreparedStatement getPhysPs() throws java.sql.SQLException
java.sql.SQLException
- if the logical statement has been closedjava.sql.CallableStatement getPhysCs() throws java.sql.SQLException
java.sql.SQLException
- if the logical statement has been closedprivate java.sql.Statement getPhysStmt() throws java.sql.SQLException
java.sql.SQLException
- if the logical statement has been closedpublic void close() throws java.sql.SQLException
close
in interface java.lang.AutoCloseable
close
in interface java.sql.Statement
java.sql.SQLException
- if closing the statement failsboolean isLogicalEntityClosed()
If this method is used to avoid the possibility of raising an exception because the logical statement has been closed and then invoke a method on the physical statement, one must synchronize on this instance in the calling code.
true
if closed, false
if open.public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
iface
.isWrapperFor
in interface java.sql.Wrapper
iface
- a class defining an interfacetrue
if this instance implements iface
, or
false
otherwisejava.sql.SQLException
- if an error occurs while determining if this
instance implements iface
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
iface
- a class defining an interfacejava.sql.SQLException
- if no object is found that implements the
interfacepublic void closeOnCompletion() throws java.sql.SQLException
closeOnCompletion
in interface java.sql.Statement
java.sql.SQLException
public boolean isCloseOnCompletion() throws java.sql.SQLException
isCloseOnCompletion
in interface java.sql.Statement
java.sql.SQLException
public long[] executeLargeBatch() throws java.sql.SQLException
executeLargeBatch
in interface java.sql.Statement
java.sql.SQLException
public long executeLargeUpdate(java.lang.String sql) throws java.sql.SQLException
executeLargeUpdate
in interface java.sql.Statement
java.sql.SQLException
public long executeLargeUpdate(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
executeLargeUpdate
in interface java.sql.Statement
java.sql.SQLException
public long executeLargeUpdate(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
executeLargeUpdate
in interface java.sql.Statement
java.sql.SQLException
public long executeLargeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
executeLargeUpdate
in interface java.sql.Statement
java.sql.SQLException
public long getLargeUpdateCount() throws java.sql.SQLException
getLargeUpdateCount
in interface java.sql.Statement
java.sql.SQLException
public long getLargeMaxRows() throws java.sql.SQLException
getLargeMaxRows
in interface java.sql.Statement
java.sql.SQLException
public void setLargeMaxRows(long maxRows) throws java.sql.SQLException
setLargeMaxRows
in interface java.sql.Statement
java.sql.SQLException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.