Package org.apache.derby.client.am
Class ClientConnection
- java.lang.Object
-
- org.apache.derby.client.am.ClientConnection
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.sql.Connection
,java.sql.Wrapper
,ConnectionCallbackInterface
- Direct Known Subclasses:
NetConnection
public abstract class ClientConnection extends java.lang.Object implements java.sql.Connection, ConnectionCallbackInterface
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
aborting_
private boolean
accumulated440ForMessageProcFailure_
private boolean
accumulated444ForMessageProcFailure_
Agent
agent_
boolean
autoCommit_
private boolean
availableForReuse_
(package private) java.util.Hashtable<java.lang.String,java.lang.String>
clientCursorNameCache_
private int
clientSSLMode_
int
commBufferSize_
(package private) java.util.WeakHashMap<UnitOfWorkListener,java.lang.Void>
CommitAndRollbackListeners_
private java.lang.String
currentSchemaName_
Cached copy of the schema name.ClientDatabaseMetaData
databaseMetaData_
java.lang.String
databaseName_
BasicClientDataSource40
dataSource_
private int
defaultIsolation
The default isolation level, enforced on connection resets.private static java.lang.String
DERBY_TRANSACTION_READ_COMMITTED
private static java.lang.String
DERBY_TRANSACTION_READ_UNCOMMITTED
private static java.lang.String
DERBY_TRANSACTION_REPEATABLE_READ
private static java.lang.String
DERBY_TRANSACTION_SERIALIZABLE
private int
dncGeneratedSavepointId_
private static java.lang.String
dncGeneratedSavepointNamePrefix__
protected EncryptionManager
encryptionManager_
private ClientPreparedStatement
getTransactionIsolationPrepStmt
private int
holdability
Holdabilty for created statements.protected boolean
inUnitOfWork_
private static int
INVALID_LOCATOR
private int
isolation_
Cached copy of the isolation level.private java.util.HashMap<java.lang.String,ClientPreparedStatement>
isolationLevelPreparedStmts
protected boolean
isXAConnection_
private boolean
jdbcReadOnly_
private CallableLocatorProcedures
lobProcs
Reference to object with prepared statements for calling the locator procedures.private int
loginTimeout_
protected boolean
open_
(package private) java.util.WeakHashMap<ClientStatement,java.lang.Void>
openStatements_
int
portNumber_
java.lang.String
productID_
boolean
resetConnectionAtFirstSql_
(package private) boolean
retrieveMessageText_
java.lang.String
serverNameIP_
private static int
TRANSACTION_UNKNOWN
Constant indicating that isolation_ has not been updated through piggy-backing, (or that the previously stored value was invalidated, e.g. by an XA state change).private int
transactionID_
protected java.lang.String
user_
private SqlWarning
warnings_
static int
XA_T0_NOT_ASSOCIATED
XA_T0_NOT_ASSOCIATED
This connection is not currently associated with an XA transaction In this state commits will flow in autocommit mode.static int
XA_T1_ASSOCIATED
XA_T1_ASSOCIATED
In this state commits will not flow in autocommit mode.int
xaHostVersion_
private int
xaState_
-
Constructor Summary
Constructors Modifier Constructor Description protected
ClientConnection(LogWriter logWriter, boolean isXAConn, BasicClientDataSource40 dataSource)
protected
ClientConnection(LogWriter logWriter, int driverManagerLoginTimeout, java.lang.String serverName, int portNumber, java.lang.String databaseName, java.util.Properties properties)
protected
ClientConnection(LogWriter logWriter, java.lang.String user, java.lang.String password, boolean isXAConn, BasicClientDataSource40 dataSource)
protected
ClientConnection(LogWriter logWriter, java.lang.String user, java.lang.String password, BasicClientDataSource40 dataSource)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
abort(java.util.concurrent.Executor executor)
(package private) void
accumulate440WarningForMessageProcFailure(SqlWarning e)
(package private) void
accumulate444WarningForMessageProcFailure(SqlWarning e)
private void
accumulateWarning(SqlWarning e)
protected abstract boolean
allowCloseInUOW_()
protected abstract boolean
allowLocalCommitRollback_()
protected void
beginAborting()
Begin aborting the connectionprotected void
checkForClosedConnection()
private void
checkForInvalidXAStateOnCommitOrRollback()
(package private) void
checkForTransactionInProgress()
Check if the transaction is in progress and the connection cannot be closed.void
clearWarnings()
private void
clearWarningsX()
void
close()
(package private) void
closeForReuse(boolean statementPooling)
void
closeResources()
private void
closeResourcesX()
private void
closeX()
void
commit()
void
completeAbnormalUnitOfWork()
void
completeAbnormalUnitOfWork(UnitOfWorkListener uwl)
Rollback the UnitOfWorkListener specifically.void
completeChainBreakingDisconnect()
void
completeConnect()
void
completeInitialPiggyBackIsolation(int pbIsolation)
Sets the default isolation level of the connection upon connection initialization.void
completeInitialPiggyBackSchema(java.lang.String pbSchema)
Sets the current schema upon connection initialization.void
completeLocalCommit()
void
completeLocalRollback()
void
completePiggyBackIsolation(int pbIsolation)
Completes piggy-backing of the new current isolation level by updating the cached copy in am.Connection.void
completePiggyBackSchema(java.lang.String pbSchema)
Completes piggy-backing of the new current schema by updating the cached copy in am.Connection.protected void
completeReset(boolean isDeferredReset, boolean closeStatementsOnClose, NetXAResource xares)
NOTE:The following comments are valid for the changes done as part of implementing statement caching only (see DERBY-3313 and linked issues).private void
completeSpecificRollback(UnitOfWorkListener uwl)
Rollback the specific UnitOfWorkListener.void
completeSqlca(Sqlca sqlca)
(package private) void
completeTransactionStart()
java.sql.Blob
createBlob()
Constructs an object that implements theBlob
interface.java.sql.Clob
createClob()
Constructs an object that implements theClob
interface.java.sql.Statement
createStatement()
java.sql.Statement
createStatement(int resultSetType, int resultSetConcurrency)
java.sql.Statement
createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
private ClientStatement
createStatementX(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
protected abstract boolean
doCloseStatementsOnClose_()
private int
downgradeResultSetType(int resultSetType)
protected void
finalize()
boolean
flowAutoCommit()
private void
flowClose()
private void
flowCommit()
protected void
flowRollback()
boolean
getAutoCommit()
java.lang.String
getCatalog()
java.lang.String
getCurrentSchemaName()
Returns the current schema (the schema that would be used for compilation.int
getHoldability()
java.sql.DatabaseMetaData
getMetaData()
int
getNetworkTimeout()
java.lang.String
getSchema()
Get the name of the current schema.int
getServerVersion()
int
getTransactionID()
Returns the ID of the active transaction for this connection.int
getTransactionIsolation()
int
getTransactionIsolationX()
java.util.Map<java.lang.String,java.lang.Class<?>>
getTypeMap()
java.sql.SQLWarning
getWarnings()
int
getXAState()
(package private) int
holdability()
Return the holdabilty for the Connection.private void
initConnection(LogWriter logWriter, BasicClientDataSource40 dataSource)
boolean
isAborting()
Return true if the connection is abortingboolean
isClosed()
boolean
isClosedX()
protected abstract boolean
isGlobalPending_()
boolean
isPhysicalConnClosed()
Return true if the physical connection is still open.boolean
isReadOnly()
boolean
isXAConnection()
void
lightReset()
(package private) CallableLocatorProcedures
locatorProcedureCall()
Get handle to the object that contains prepared statements for calling locator procedures for this connection.private void
markClosed(boolean statementPooling)
protected abstract void
markClosed_()
private void
markClosedForReuse(boolean statementPooling)
private void
markStatementsClosed()
java.lang.String
nativeSQL(java.lang.String sql)
(package private) java.lang.String
nativeSQLX(java.lang.String sql)
protected abstract Agent
newAgent_(LogWriter logWriter, int loginTimeout, java.lang.String serverName, int portNumber, int clientSSLMode)
protected abstract ClientCallableStatement
newCallableStatement_(java.lang.String sql, int type, int concurrency, int holdability)
protected abstract ClientDatabaseMetaData
newDatabaseMetaData_()
protected abstract ClientPreparedStatement
newPositionedUpdatePreparedStatement_(java.lang.String sql, Section section)
protected abstract ClientPreparedStatement
newPreparedStatement_(java.lang.String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)
abstract SectionManager
newSectionManager(Agent agent)
protected abstract ClientStatement
newStatement_(int type, int concurrency, int holdability)
java.sql.CallableStatement
prepareCall(java.lang.String sql)
java.sql.CallableStatement
prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
java.sql.CallableStatement
prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
(package private) ClientCallableStatement
prepareCallX(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
(package private) ClientPreparedStatement
prepareDynamicCatalogQuery(java.lang.String sql)
(package private) ClientCallableStatement
prepareMessageProc(java.lang.String sql)
(package private) ClientPreparedStatement
preparePositionedUpdateStatement(java.lang.String sql, Section querySection)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, int autoGeneratedKeys)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, int[] columnIndexes)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, java.lang.String[] columnNames)
(package private) ClientPreparedStatement
prepareStatementX(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)
(package private) void
readAutoCommit()
private void
readCloseStatements()
(package private) void
readCommit()
abstract void
readCommitSubstitute_()
abstract void
readLocalCommit_()
abstract void
readLocalRollback_()
abstract void
readLocalXACommit_()
abstract void
readLocalXARollback_()
abstract void
readLocalXAStart_()
private void
readRollback()
void
readTransactionStart()
protected abstract void
readXACommit_()
protected abstract void
readXARollback_()
void
releaseSavepoint(java.sql.Savepoint savepoint)
void
reset(LogWriter logWriter)
protected abstract void
reset_(LogWriter logWriter)
protected abstract void
resetCallableStatement_(ClientCallableStatement cs, java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
protected void
resetConnection(LogWriter logWriter)
protected void
resetPrepareCall(ClientCallableStatement cs)
protected abstract void
resetPreparedStatement_(ClientPreparedStatement ps, java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)
protected void
resetPrepareStatement(ClientPreparedStatement ps)
protected void
resetStatement(ClientStatement s)
protected abstract void
resetStatement_(ClientStatement statement, int type, int concurrency, int holdability)
void
rollback()
void
rollback(java.sql.Savepoint savepoint)
protected abstract boolean
serverSupportsLocators()
Checks whether the server supports locators for large objects.protected abstract boolean
serverSupportsTimestampNanoseconds()
Return true if the server supports nanoseconds in timestampsvoid
setAutoCommit(boolean autoCommit)
void
setCatalog(java.lang.String catalog)
void
setHoldability(int holdability)
void
setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds)
void
setReadOnly(boolean readOnly)
java.sql.Savepoint
setSavepoint()
java.sql.Savepoint
setSavepoint(java.lang.String name)
private ClientSavepoint
setSavepointX(ClientSavepoint savepoint)
void
setSchema(java.lang.String schemaName)
Set the default schema for the Connection.void
setTransactionIsolation(int level)
private void
setTransactionIsolationX(int level)
Set the transaction isolation level as specified.void
setTypeMap(java.util.Map map)
void
setXAState(int state)
protected abstract boolean
supportsSessionDataCaching()
Finds out if the underlaying database connection supports session data caching.boolean
transactionInProgress()
Check if there are uncommitted operations in the current transaction that prevent us from closing the connection.private int
translateIsolation(java.lang.String isolationStr)
Translates the isolation level from a SQL string to the JDBC int valueboolean
willAutoCommitGenerateFlow()
(package private) void
writeAutoCommit()
private void
writeCloseStatements()
(package private) void
writeCommit()
abstract void
writeCommitSubstitute_()
abstract void
writeLocalCommit_()
abstract void
writeLocalRollback_()
abstract void
writeLocalXACommit_()
abstract void
writeLocalXARollback_()
abstract void
writeLocalXAStart_()
private void
writeRollback()
void
writeTransactionStart(ClientStatement statement)
protected abstract void
writeXACommit_()
protected abstract void
writeXARollback_()
protected abstract void
writeXATransactionStart(ClientStatement statement)
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
agent_
public Agent agent_
-
databaseMetaData_
public ClientDatabaseMetaData databaseMetaData_
-
openStatements_
final java.util.WeakHashMap<ClientStatement,java.lang.Void> openStatements_
-
CommitAndRollbackListeners_
final java.util.WeakHashMap<UnitOfWorkListener,java.lang.Void> CommitAndRollbackListeners_
-
warnings_
private SqlWarning warnings_
-
INVALID_LOCATOR
private static final int INVALID_LOCATOR
- See Also:
- Constant Field Values
-
user_
protected final java.lang.String user_
-
retrieveMessageText_
boolean retrieveMessageText_
-
jdbcReadOnly_
private boolean jdbcReadOnly_
-
holdability
private int holdability
Holdabilty for created statements. Only access through the holdability method to ensure the correct value is returned for an XA connection.
-
databaseName_
public java.lang.String databaseName_
-
productID_
public java.lang.String productID_
-
encryptionManager_
protected EncryptionManager encryptionManager_
-
isolationLevelPreparedStmts
private final java.util.HashMap<java.lang.String,ClientPreparedStatement> isolationLevelPreparedStmts
-
getTransactionIsolationPrepStmt
private ClientPreparedStatement getTransactionIsolationPrepStmt
-
open_
protected boolean open_
-
aborting_
private boolean aborting_
-
availableForReuse_
private boolean availableForReuse_
-
TRANSACTION_UNKNOWN
private static final int TRANSACTION_UNKNOWN
Constant indicating that isolation_ has not been updated through piggy-backing, (or that the previously stored value was invalidated, e.g. by an XA state change).- See Also:
- Constant Field Values
-
isolation_
private int isolation_
Cached copy of the isolation level. Kept in sync with server through piggy-backing.
-
defaultIsolation
private int defaultIsolation
The default isolation level, enforced on connection resets.Note that this value may be changed upon connection initialization in the future, as the server can piggy-back the isolation level.
-
currentSchemaName_
private java.lang.String currentSchemaName_
Cached copy of the schema name. Updated through piggy-backing and used to implement statement caching.
-
autoCommit_
public boolean autoCommit_
-
inUnitOfWork_
protected boolean inUnitOfWork_
-
accumulated440ForMessageProcFailure_
private boolean accumulated440ForMessageProcFailure_
-
accumulated444ForMessageProcFailure_
private boolean accumulated444ForMessageProcFailure_
-
transactionID_
private int transactionID_
-
isXAConnection_
protected boolean isXAConnection_
-
XA_T0_NOT_ASSOCIATED
public static final int XA_T0_NOT_ASSOCIATED
XA_T0_NOT_ASSOCIATED
This connection is not currently associated with an XA transaction In this state commits will flow in autocommit mode.- See Also:
- Constant Field Values
-
XA_T1_ASSOCIATED
public static final int XA_T1_ASSOCIATED
XA_T1_ASSOCIATED
In this state commits will not flow in autocommit mode.- See Also:
- Constant Field Values
-
xaState_
private int xaState_
-
xaHostVersion_
public int xaHostVersion_
-
loginTimeout_
private int loginTimeout_
-
dataSource_
public BasicClientDataSource40 dataSource_
-
serverNameIP_
public java.lang.String serverNameIP_
-
portNumber_
public int portNumber_
-
clientSSLMode_
private int clientSSLMode_
-
clientCursorNameCache_
java.util.Hashtable<java.lang.String,java.lang.String> clientCursorNameCache_
-
commBufferSize_
public int commBufferSize_
-
resetConnectionAtFirstSql_
public boolean resetConnectionAtFirstSql_
-
DERBY_TRANSACTION_REPEATABLE_READ
private static java.lang.String DERBY_TRANSACTION_REPEATABLE_READ
-
DERBY_TRANSACTION_SERIALIZABLE
private static java.lang.String DERBY_TRANSACTION_SERIALIZABLE
-
DERBY_TRANSACTION_READ_COMMITTED
private static java.lang.String DERBY_TRANSACTION_READ_COMMITTED
-
DERBY_TRANSACTION_READ_UNCOMMITTED
private static java.lang.String DERBY_TRANSACTION_READ_UNCOMMITTED
-
dncGeneratedSavepointId_
private int dncGeneratedSavepointId_
-
dncGeneratedSavepointNamePrefix__
private static final java.lang.String dncGeneratedSavepointNamePrefix__
- See Also:
- Constant Field Values
-
lobProcs
private CallableLocatorProcedures lobProcs
Reference to object with prepared statements for calling the locator procedures. Makes it possible to reuse prepared statements within the connection.
-
-
Constructor Detail
-
ClientConnection
protected ClientConnection(LogWriter logWriter, java.lang.String user, java.lang.String password, BasicClientDataSource40 dataSource) throws SqlException
- Throws:
SqlException
-
ClientConnection
protected ClientConnection(LogWriter logWriter, java.lang.String user, java.lang.String password, boolean isXAConn, BasicClientDataSource40 dataSource) throws SqlException
- Throws:
SqlException
-
ClientConnection
protected ClientConnection(LogWriter logWriter, boolean isXAConn, BasicClientDataSource40 dataSource) throws SqlException
- Throws:
SqlException
-
ClientConnection
protected ClientConnection(LogWriter logWriter, int driverManagerLoginTimeout, java.lang.String serverName, int portNumber, java.lang.String databaseName, java.util.Properties properties) throws SqlException
- Throws:
SqlException
-
-
Method Detail
-
initConnection
private void initConnection(LogWriter logWriter, BasicClientDataSource40 dataSource) throws SqlException
- Throws:
SqlException
-
resetConnection
protected void resetConnection(LogWriter logWriter) throws SqlException
- Throws:
SqlException
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
createStatement
public java.sql.Statement createStatement() throws java.sql.SQLException
- Specified by:
createStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
preparePositionedUpdateStatement
ClientPreparedStatement preparePositionedUpdateStatement(java.lang.String sql, Section querySection) throws SqlException
- Throws:
SqlException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
- Specified by:
prepareCall
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareDynamicCatalogQuery
ClientPreparedStatement prepareDynamicCatalogQuery(java.lang.String sql) throws SqlException
- Throws:
SqlException
-
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException
- Specified by:
nativeSQL
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
nativeSQLX
java.lang.String nativeSQLX(java.lang.String sql) throws SqlException
- Throws:
SqlException
-
allowLocalCommitRollback_
protected abstract boolean allowLocalCommitRollback_() throws SqlException
- Throws:
SqlException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException
- Specified by:
setAutoCommit
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getAutoCommit
public boolean getAutoCommit() throws java.sql.SQLException
- Specified by:
getAutoCommit
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
commit
public void commit() throws java.sql.SQLException
- Specified by:
commit
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
checkForInvalidXAStateOnCommitOrRollback
private void checkForInvalidXAStateOnCommitOrRollback() throws SqlException
- Throws:
SqlException
-
flowCommit
private void flowCommit() throws SqlException
- Throws:
SqlException
-
flowAutoCommit
public boolean flowAutoCommit() throws SqlException
- Throws:
SqlException
-
willAutoCommitGenerateFlow
public boolean willAutoCommitGenerateFlow() throws SqlException
- Throws:
SqlException
-
writeAutoCommit
void writeAutoCommit() throws SqlException
- Throws:
SqlException
-
writeCommit
void writeCommit() throws SqlException
- Throws:
SqlException
-
readAutoCommit
void readAutoCommit() throws SqlException
- Throws:
SqlException
-
readCommit
void readCommit() throws SqlException
- Throws:
SqlException
-
rollback
public void rollback() throws java.sql.SQLException
- Specified by:
rollback
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
flowRollback
protected void flowRollback() throws SqlException
- Throws:
SqlException
-
writeRollback
private void writeRollback() throws SqlException
- Throws:
SqlException
-
readRollback
private void readRollback() throws SqlException
- Throws:
SqlException
-
close
public void close() throws java.sql.SQLException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
checkForTransactionInProgress
void checkForTransactionInProgress() throws SqlException
Check if the transaction is in progress and the connection cannot be closed.- Throws:
SqlException
- if the connection cannot be closed because the transaction is active
-
transactionInProgress
public boolean transactionInProgress()
Check if there are uncommitted operations in the current transaction that prevent us from closing the connection.- Returns:
true
if the connection cannot be closed due to uncommitted operations in the transaction
-
closeX
private void closeX() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
closeResources
public void closeResources() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
closeResourcesX
private void closeResourcesX() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
isGlobalPending_
protected abstract boolean isGlobalPending_()
-
closeForReuse
void closeForReuse(boolean statementPooling) throws SqlException
- Throws:
SqlException
-
flowClose
private void flowClose() throws SqlException
- Throws:
SqlException
-
markClosed_
protected abstract void markClosed_()
-
markClosed
private void markClosed(boolean statementPooling)
-
markClosedForReuse
private void markClosedForReuse(boolean statementPooling)
-
markStatementsClosed
private void markStatementsClosed()
-
writeCloseStatements
private void writeCloseStatements() throws SqlException
- Throws:
SqlException
-
readCloseStatements
private void readCloseStatements() throws SqlException
- Throws:
SqlException
-
isPhysicalConnClosed
public boolean isPhysicalConnClosed()
Return true if the physical connection is still open. Might be logically closed but available for reuse.- Returns:
- true if physical connection still open
-
isClosed
public boolean isClosed()
- Specified by:
isClosed
in interfacejava.sql.Connection
-
isClosedX
public boolean isClosedX()
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws java.sql.SQLException
- Specified by:
setTransactionIsolation
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setTransactionIsolationX
private void setTransactionIsolationX(int level) throws SqlException
Set the transaction isolation level as specified.If this method is called during a transaction, the result is implementation-defined.
Information about Derby specific isolation level handling:
- REPEATABLE_READ = JDBC: TRANSACTION_SERIALIZABLE, DERBY: RR, PROTOCOL: repeatable read
- READ_STABILITY = JDBC: TRANSACTION_REPEATABLE_READ, DERBY: RS, PROTOCOL: All
- CURSOR_STABILITY = JDBC: TRANSACTION_READ_COMMITTED, DERBY: CS, PROTOCOL: Cursor stability
- UNCOMMITTED_READ = JDBC: TRANSACTION_READ_UNCOMMITTED, DERBY: UR, PROTOCOL: Change
- NO_COMMIT = JDBC: TRANSACTION_NONE, DERBY: NC, PROTOCOL: No commit
- Throws:
SqlException
-
supportsSessionDataCaching
protected abstract boolean supportsSessionDataCaching()
Finds out if the underlaying database connection supports session data caching.- Returns:
- true if sessionData is supported
-
serverSupportsLocators
protected abstract boolean serverSupportsLocators()
Checks whether the server supports locators for large objects. Note that even though the server supports LOB locators, the database that is accessed through the server may not have the necessary stored procedures to support LOB locators (e.g., because the database is soft upgraded from an earlier version).- Returns:
true
if LOB locators are supported.
-
serverSupportsTimestampNanoseconds
protected abstract boolean serverSupportsTimestampNanoseconds()
Return true if the server supports nanoseconds in timestamps
-
getTransactionIsolation
public int getTransactionIsolation() throws java.sql.SQLException
- Specified by:
getTransactionIsolation
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getTransactionIsolationX
public int getTransactionIsolationX() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getTransactionID
public int getTransactionID()
Returns the ID of the active transaction for this connection.- Returns:
- the ID of the active transaction
-
getCurrentSchemaName
public java.lang.String getCurrentSchemaName() throws java.sql.SQLException
Returns the current schema (the schema that would be used for compilation. This is not part of the java.sql.Connection interface, and is only intended for use with statement caching.- Returns:
- the name of the current schema
- Throws:
java.sql.SQLException
-
translateIsolation
private int translateIsolation(java.lang.String isolationStr)
Translates the isolation level from a SQL string to the JDBC int value- Parameters:
isolationStr
- SQL isolation string- Returns:
- isolation level as a JDBC integer value
-
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
- Specified by:
getWarnings
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
clearWarnings
public void clearWarnings() throws java.sql.SQLException
- Specified by:
clearWarnings
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
clearWarningsX
private void clearWarningsX() throws SqlException
- Throws:
SqlException
-
getMetaData
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
- Specified by:
getMetaData
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws java.sql.SQLException
- Specified by:
setReadOnly
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
isReadOnly
public boolean isReadOnly() throws java.sql.SQLException
- Specified by:
isReadOnly
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setCatalog
public void setCatalog(java.lang.String catalog) throws java.sql.SQLException
- Specified by:
setCatalog
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getCatalog
public java.lang.String getCatalog() throws java.sql.SQLException
- Specified by:
getCatalog
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createStatement
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
- Specified by:
createStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
- Specified by:
prepareCall
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareMessageProc
ClientCallableStatement prepareMessageProc(java.lang.String sql) throws SqlException
- Throws:
SqlException
-
downgradeResultSetType
private int downgradeResultSetType(int resultSetType)
-
getTypeMap
public java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap() throws java.sql.SQLException
- Specified by:
getTypeMap
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setTypeMap
public void setTypeMap(java.util.Map map) throws java.sql.SQLException
- Specified by:
setTypeMap
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setHoldability
public void setHoldability(int holdability) throws java.sql.SQLException
- Specified by:
setHoldability
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getHoldability
public int getHoldability() throws java.sql.SQLException
- Specified by:
getHoldability
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException
- Specified by:
setSavepoint
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException
- Specified by:
setSavepoint
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setSavepointX
private ClientSavepoint setSavepointX(ClientSavepoint savepoint) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
rollback
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException
- Specified by:
rollback
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
releaseSavepoint
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException
- Specified by:
releaseSavepoint
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createStatement
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
- Specified by:
createStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createStatementX
private ClientStatement createStatementX(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SqlException
- Throws:
SqlException
-
resetStatement
protected void resetStatement(ClientStatement s) throws SqlException
- Throws:
SqlException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareStatementX
ClientPreparedStatement prepareStatementX(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes) throws SqlException
- Throws:
SqlException
-
resetPrepareStatement
protected void resetPrepareStatement(ClientPreparedStatement ps) throws SqlException
- Throws:
SqlException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
- Specified by:
prepareCall
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareCallX
ClientCallableStatement prepareCallX(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SqlException
- Throws:
SqlException
-
resetPrepareCall
protected void resetPrepareCall(ClientCallableStatement cs) throws SqlException
- Throws:
SqlException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
allowCloseInUOW_
protected abstract boolean allowCloseInUOW_()
-
doCloseStatementsOnClose_
protected abstract boolean doCloseStatementsOnClose_()
-
newSectionManager
public abstract SectionManager newSectionManager(Agent agent)
-
newAgent_
protected abstract Agent newAgent_(LogWriter logWriter, int loginTimeout, java.lang.String serverName, int portNumber, int clientSSLMode) throws SqlException
- Throws:
SqlException
-
newDatabaseMetaData_
protected abstract ClientDatabaseMetaData newDatabaseMetaData_()
-
newStatement_
protected abstract ClientStatement newStatement_(int type, int concurrency, int holdability) throws SqlException
- Throws:
SqlException
-
resetStatement_
protected abstract void resetStatement_(ClientStatement statement, int type, int concurrency, int holdability) throws SqlException
- Throws:
SqlException
-
newPositionedUpdatePreparedStatement_
protected abstract ClientPreparedStatement newPositionedUpdatePreparedStatement_(java.lang.String sql, Section section) throws SqlException
- Throws:
SqlException
-
newPreparedStatement_
protected abstract ClientPreparedStatement newPreparedStatement_(java.lang.String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes) throws SqlException
- Throws:
SqlException
-
resetPreparedStatement_
protected abstract void resetPreparedStatement_(ClientPreparedStatement ps, java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes) throws SqlException
- Throws:
SqlException
-
newCallableStatement_
protected abstract ClientCallableStatement newCallableStatement_(java.lang.String sql, int type, int concurrency, int holdability) throws SqlException
- Throws:
SqlException
-
resetCallableStatement_
protected abstract void resetCallableStatement_(ClientCallableStatement cs, java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SqlException
- Throws:
SqlException
-
completeConnect
public final void completeConnect() throws SqlException
- Throws:
SqlException
-
writeCommitSubstitute_
public abstract void writeCommitSubstitute_() throws SqlException
- Throws:
SqlException
-
readCommitSubstitute_
public abstract void readCommitSubstitute_() throws SqlException
- Throws:
SqlException
-
writeLocalXAStart_
public abstract void writeLocalXAStart_() throws SqlException
- Throws:
SqlException
-
readLocalXAStart_
public abstract void readLocalXAStart_() throws SqlException
- Throws:
SqlException
-
writeLocalXACommit_
public abstract void writeLocalXACommit_() throws SqlException
- Throws:
SqlException
-
writeXACommit_
protected abstract void writeXACommit_() throws SqlException
- Throws:
SqlException
-
readLocalXACommit_
public abstract void readLocalXACommit_() throws SqlException
- Throws:
SqlException
-
readXACommit_
protected abstract void readXACommit_() throws SqlException
- Throws:
SqlException
-
writeLocalCommit_
public abstract void writeLocalCommit_() throws SqlException
- Throws:
SqlException
-
readLocalCommit_
public abstract void readLocalCommit_() throws SqlException
- Throws:
SqlException
-
writeXATransactionStart
protected abstract void writeXATransactionStart(ClientStatement statement) throws SqlException
- Throws:
SqlException
-
completeLocalCommit
public void completeLocalCommit()
- Specified by:
completeLocalCommit
in interfaceConnectionCallbackInterface
-
writeLocalRollback_
public abstract void writeLocalRollback_() throws SqlException
- Throws:
SqlException
-
readLocalRollback_
public abstract void readLocalRollback_() throws SqlException
- Throws:
SqlException
-
completeLocalRollback
public void completeLocalRollback()
- Specified by:
completeLocalRollback
in interfaceConnectionCallbackInterface
-
completeSpecificRollback
private void completeSpecificRollback(UnitOfWorkListener uwl)
Rollback the specific UnitOfWorkListener.- Parameters:
uwl
- The UnitOfWorkLitener to be rolled back
-
writeLocalXARollback_
public abstract void writeLocalXARollback_() throws SqlException
- Throws:
SqlException
-
writeXARollback_
protected abstract void writeXARollback_() throws SqlException
- Throws:
SqlException
-
readLocalXARollback_
public abstract void readLocalXARollback_() throws SqlException
- Throws:
SqlException
-
readXARollback_
protected abstract void readXARollback_() throws SqlException
- Throws:
SqlException
-
writeTransactionStart
public void writeTransactionStart(ClientStatement statement) throws SqlException
- Throws:
SqlException
-
readTransactionStart
public void readTransactionStart() throws SqlException
- Throws:
SqlException
-
completeTransactionStart
void completeTransactionStart()
-
completeAbnormalUnitOfWork
public void completeAbnormalUnitOfWork()
- Specified by:
completeAbnormalUnitOfWork
in interfaceConnectionCallbackInterface
-
completeAbnormalUnitOfWork
public void completeAbnormalUnitOfWork(UnitOfWorkListener uwl)
Rollback the UnitOfWorkListener specifically.- Specified by:
completeAbnormalUnitOfWork
in interfaceConnectionCallbackInterface
- Parameters:
uwl
- The UnitOfWorkListener to be rolled back.
-
completeChainBreakingDisconnect
public void completeChainBreakingDisconnect()
- Specified by:
completeChainBreakingDisconnect
in interfaceConnectionCallbackInterface
-
completeSqlca
public void completeSqlca(Sqlca sqlca)
- Specified by:
completeSqlca
in interfaceConnectionCallbackInterface
-
completePiggyBackIsolation
public void completePiggyBackIsolation(int pbIsolation)
Description copied from interface:ConnectionCallbackInterface
Completes piggy-backing of the new current isolation level by updating the cached copy in am.Connection.- Specified by:
completePiggyBackIsolation
in interfaceConnectionCallbackInterface
- Parameters:
pbIsolation
- new isolation level from the server
-
completeInitialPiggyBackIsolation
public void completeInitialPiggyBackIsolation(int pbIsolation)
Sets the default isolation level of the connection upon connection initialization.Note that depending on the server version, the default isolation value may not be piggy-backed on the initialization flow. In that case, the default is assumed / hardcoded to be READ_COMMITTED.
- Parameters:
pbIsolation
- isolation level as specified byjava.sql.Connection
-
completePiggyBackSchema
public void completePiggyBackSchema(java.lang.String pbSchema)
Description copied from interface:ConnectionCallbackInterface
Completes piggy-backing of the new current schema by updating the cached copy in am.Connection.- Specified by:
completePiggyBackSchema
in interfaceConnectionCallbackInterface
- Parameters:
pbSchema
- new current schema from the server
-
completeInitialPiggyBackSchema
public void completeInitialPiggyBackSchema(java.lang.String pbSchema)
Sets the current schema upon connection initialization.- Parameters:
pbSchema
- the schema name
-
reset
public void reset(LogWriter logWriter) throws SqlException
- Throws:
SqlException
-
lightReset
public void lightReset() throws SqlException
- Throws:
SqlException
-
reset_
protected abstract void reset_(LogWriter logWriter) throws SqlException
- Throws:
SqlException
-
completeReset
protected void completeReset(boolean isDeferredReset, boolean closeStatementsOnClose, NetXAResource xares) throws SqlException
NOTE:The following comments are valid for the changes done as part of implementing statement caching only (see DERBY-3313 and linked issues).We don't reset the isolation level to unknown unconditionally, as this forces us to go to the server all the time. Since the value should now be valid (DERBY-3192), we check if it has been changed from the default.
- Parameters:
closeStatementsOnClose
- is used to differentiate between cases where statement pooling is enabled or not. Iftrue
, it means statement pooling is disabled and the statements are fully reset, which includes a re-prepare. Iffalse
, statement pooling is enabled, and a more lightweight reset procedure is used.- Throws:
SqlException
-
locatorProcedureCall
CallableLocatorProcedures locatorProcedureCall()
Get handle to the object that contains prepared statements for calling locator procedures for this connection. The object will be created on the first invocation. An example of how to call a stored procedure via this method:connection.locatorProcedureCall().blobReleaseLocator(locator);
- Returns:
- object with prepared statements for calling locator procedures
-
checkForClosedConnection
protected void checkForClosedConnection() throws SqlException
- Throws:
SqlException
-
isXAConnection
public boolean isXAConnection()
-
getXAState
public int getXAState()
-
setXAState
public void setXAState(int state)
-
accumulateWarning
private void accumulateWarning(SqlWarning e)
-
accumulate440WarningForMessageProcFailure
void accumulate440WarningForMessageProcFailure(SqlWarning e)
-
accumulate444WarningForMessageProcFailure
void accumulate444WarningForMessageProcFailure(SqlWarning e)
-
getServerVersion
public int getServerVersion()
-
holdability
final int holdability()
Return the holdabilty for the Connection. Matches the embedded driver in the restriction that while in a global (XA) transaction the holdability is CLOSE_CURSORS_AT_COMMIT. Otherwise return the holdability set by the user.
-
createClob
public java.sql.Clob createClob() throws java.sql.SQLException
Constructs an object that implements theClob
interface. The object returned initially contains no data.- Specified by:
createClob
in interfacejava.sql.Connection
- Returns:
- An object that implements the
Clob
interface - Throws:
java.sql.SQLException
- if an object that implements theClob
interface can not be constructed.
-
createBlob
public java.sql.Blob createBlob() throws java.sql.SQLException
Constructs an object that implements theBlob
interface. The object returned initially contains no data.- Specified by:
createBlob
in interfacejava.sql.Connection
- Returns:
- An object that implements the
Blob
interface - Throws:
java.sql.SQLException
- if an object that implements the Blob interface can not be constructed.
-
isAborting
public boolean isAborting()
Return true if the connection is aborting
-
beginAborting
protected void beginAborting()
Begin aborting the connection
-
getSchema
public java.lang.String getSchema() throws java.sql.SQLException
Get the name of the current schema.- Specified by:
getSchema
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setSchema
public void setSchema(java.lang.String schemaName) throws java.sql.SQLException
Set the default schema for the Connection.- Specified by:
setSchema
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
abort
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException
- Specified by:
abort
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws java.sql.SQLException
- Specified by:
getNetworkTimeout
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setNetworkTimeout
public void setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds) throws java.sql.SQLException
- Specified by:
setNetworkTimeout
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
-