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 booleanaborting_private booleanaccumulated440ForMessageProcFailure_private booleanaccumulated444ForMessageProcFailure_Agentagent_booleanautoCommit_private booleanavailableForReuse_(package private) java.util.Hashtable<java.lang.String,java.lang.String>clientCursorNameCache_private intclientSSLMode_intcommBufferSize_(package private) java.util.WeakHashMap<UnitOfWorkListener,java.lang.Void>CommitAndRollbackListeners_private java.lang.StringcurrentSchemaName_Cached copy of the schema name.ClientDatabaseMetaDatadatabaseMetaData_java.lang.StringdatabaseName_BasicClientDataSource40dataSource_private intdefaultIsolationThe default isolation level, enforced on connection resets.private static java.lang.StringDERBY_TRANSACTION_READ_COMMITTEDprivate static java.lang.StringDERBY_TRANSACTION_READ_UNCOMMITTEDprivate static java.lang.StringDERBY_TRANSACTION_REPEATABLE_READprivate static java.lang.StringDERBY_TRANSACTION_SERIALIZABLEprivate intdncGeneratedSavepointId_private static java.lang.StringdncGeneratedSavepointNamePrefix__protected EncryptionManagerencryptionManager_private ClientPreparedStatementgetTransactionIsolationPrepStmtprivate intholdabilityHoldabilty for created statements.protected booleaninUnitOfWork_private static intINVALID_LOCATORprivate intisolation_Cached copy of the isolation level.private java.util.HashMap<java.lang.String,ClientPreparedStatement>isolationLevelPreparedStmtsprotected booleanisXAConnection_private booleanjdbcReadOnly_private CallableLocatorProcedureslobProcsReference to object with prepared statements for calling the locator procedures.private intloginTimeout_protected booleanopen_(package private) java.util.WeakHashMap<ClientStatement,java.lang.Void>openStatements_intportNumber_java.lang.StringproductID_booleanresetConnectionAtFirstSql_(package private) booleanretrieveMessageText_java.lang.StringserverNameIP_private static intTRANSACTION_UNKNOWNConstant 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 inttransactionID_protected java.lang.Stringuser_private SqlWarningwarnings_static intXA_T0_NOT_ASSOCIATEDXA_T0_NOT_ASSOCIATEDThis connection is not currently associated with an XA transaction In this state commits will flow in autocommit mode.static intXA_T1_ASSOCIATEDXA_T1_ASSOCIATEDIn this state commits will not flow in autocommit mode.intxaHostVersion_private intxaState_
-
Constructor Summary
Constructors Modifier Constructor Description protectedClientConnection(LogWriter logWriter, boolean isXAConn, BasicClientDataSource40 dataSource)protectedClientConnection(LogWriter logWriter, int driverManagerLoginTimeout, java.lang.String serverName, int portNumber, java.lang.String databaseName, java.util.Properties properties)protectedClientConnection(LogWriter logWriter, java.lang.String user, java.lang.String password, boolean isXAConn, BasicClientDataSource40 dataSource)protectedClientConnection(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 voidabort(java.util.concurrent.Executor executor)(package private) voidaccumulate440WarningForMessageProcFailure(SqlWarning e)(package private) voidaccumulate444WarningForMessageProcFailure(SqlWarning e)private voidaccumulateWarning(SqlWarning e)protected abstract booleanallowCloseInUOW_()protected abstract booleanallowLocalCommitRollback_()protected voidbeginAborting()Begin aborting the connectionprotected voidcheckForClosedConnection()private voidcheckForInvalidXAStateOnCommitOrRollback()(package private) voidcheckForTransactionInProgress()Check if the transaction is in progress and the connection cannot be closed.voidclearWarnings()private voidclearWarningsX()voidclose()(package private) voidcloseForReuse(boolean statementPooling)voidcloseResources()private voidcloseResourcesX()private voidcloseX()voidcommit()voidcompleteAbnormalUnitOfWork()voidcompleteAbnormalUnitOfWork(UnitOfWorkListener uwl)Rollback the UnitOfWorkListener specifically.voidcompleteChainBreakingDisconnect()voidcompleteConnect()voidcompleteInitialPiggyBackIsolation(int pbIsolation)Sets the default isolation level of the connection upon connection initialization.voidcompleteInitialPiggyBackSchema(java.lang.String pbSchema)Sets the current schema upon connection initialization.voidcompleteLocalCommit()voidcompleteLocalRollback()voidcompletePiggyBackIsolation(int pbIsolation)Completes piggy-backing of the new current isolation level by updating the cached copy in am.Connection.voidcompletePiggyBackSchema(java.lang.String pbSchema)Completes piggy-backing of the new current schema by updating the cached copy in am.Connection.protected voidcompleteReset(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 voidcompleteSpecificRollback(UnitOfWorkListener uwl)Rollback the specific UnitOfWorkListener.voidcompleteSqlca(Sqlca sqlca)(package private) voidcompleteTransactionStart()java.sql.BlobcreateBlob()Constructs an object that implements theBlobinterface.java.sql.ClobcreateClob()Constructs an object that implements theClobinterface.java.sql.StatementcreateStatement()java.sql.StatementcreateStatement(int resultSetType, int resultSetConcurrency)java.sql.StatementcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)private ClientStatementcreateStatementX(int resultSetType, int resultSetConcurrency, int resultSetHoldability)protected abstract booleandoCloseStatementsOnClose_()private intdowngradeResultSetType(int resultSetType)protected voidfinalize()booleanflowAutoCommit()private voidflowClose()private voidflowCommit()protected voidflowRollback()booleangetAutoCommit()java.lang.StringgetCatalog()java.lang.StringgetCurrentSchemaName()Returns the current schema (the schema that would be used for compilation.intgetHoldability()java.sql.DatabaseMetaDatagetMetaData()intgetNetworkTimeout()java.lang.StringgetSchema()Get the name of the current schema.intgetServerVersion()intgetTransactionID()Returns the ID of the active transaction for this connection.intgetTransactionIsolation()intgetTransactionIsolationX()java.util.Map<java.lang.String,java.lang.Class<?>>getTypeMap()java.sql.SQLWarninggetWarnings()intgetXAState()(package private) intholdability()Return the holdabilty for the Connection.private voidinitConnection(LogWriter logWriter, BasicClientDataSource40 dataSource)booleanisAborting()Return true if the connection is abortingbooleanisClosed()booleanisClosedX()protected abstract booleanisGlobalPending_()booleanisPhysicalConnClosed()Return true if the physical connection is still open.booleanisReadOnly()booleanisXAConnection()voidlightReset()(package private) CallableLocatorProcedureslocatorProcedureCall()Get handle to the object that contains prepared statements for calling locator procedures for this connection.private voidmarkClosed(boolean statementPooling)protected abstract voidmarkClosed_()private voidmarkClosedForReuse(boolean statementPooling)private voidmarkStatementsClosed()java.lang.StringnativeSQL(java.lang.String sql)(package private) java.lang.StringnativeSQLX(java.lang.String sql)protected abstract AgentnewAgent_(LogWriter logWriter, int loginTimeout, java.lang.String serverName, int portNumber, int clientSSLMode)protected abstract ClientCallableStatementnewCallableStatement_(java.lang.String sql, int type, int concurrency, int holdability)protected abstract ClientDatabaseMetaDatanewDatabaseMetaData_()protected abstract ClientPreparedStatementnewPositionedUpdatePreparedStatement_(java.lang.String sql, Section section)protected abstract ClientPreparedStatementnewPreparedStatement_(java.lang.String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)abstract SectionManagernewSectionManager(Agent agent)protected abstract ClientStatementnewStatement_(int type, int concurrency, int holdability)java.sql.CallableStatementprepareCall(java.lang.String sql)java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)(package private) ClientCallableStatementprepareCallX(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)(package private) ClientPreparedStatementprepareDynamicCatalogQuery(java.lang.String sql)(package private) ClientCallableStatementprepareMessageProc(java.lang.String sql)(package private) ClientPreparedStatementpreparePositionedUpdateStatement(java.lang.String sql, Section querySection)java.sql.PreparedStatementprepareStatement(java.lang.String sql)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int autoGeneratedKeys)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int[] columnIndexes)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)java.sql.PreparedStatementprepareStatement(java.lang.String sql, java.lang.String[] columnNames)(package private) ClientPreparedStatementprepareStatementX(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)(package private) voidreadAutoCommit()private voidreadCloseStatements()(package private) voidreadCommit()abstract voidreadCommitSubstitute_()abstract voidreadLocalCommit_()abstract voidreadLocalRollback_()abstract voidreadLocalXACommit_()abstract voidreadLocalXARollback_()abstract voidreadLocalXAStart_()private voidreadRollback()voidreadTransactionStart()protected abstract voidreadXACommit_()protected abstract voidreadXARollback_()voidreleaseSavepoint(java.sql.Savepoint savepoint)voidreset(LogWriter logWriter)protected abstract voidreset_(LogWriter logWriter)protected abstract voidresetCallableStatement_(ClientCallableStatement cs, java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)protected voidresetConnection(LogWriter logWriter)protected voidresetPrepareCall(ClientCallableStatement cs)protected abstract voidresetPreparedStatement_(ClientPreparedStatement ps, java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, java.lang.String[] columnNames, int[] columnIndexes)protected voidresetPrepareStatement(ClientPreparedStatement ps)protected voidresetStatement(ClientStatement s)protected abstract voidresetStatement_(ClientStatement statement, int type, int concurrency, int holdability)voidrollback()voidrollback(java.sql.Savepoint savepoint)protected abstract booleanserverSupportsLocators()Checks whether the server supports locators for large objects.protected abstract booleanserverSupportsTimestampNanoseconds()Return true if the server supports nanoseconds in timestampsvoidsetAutoCommit(boolean autoCommit)voidsetCatalog(java.lang.String catalog)voidsetHoldability(int holdability)voidsetNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds)voidsetReadOnly(boolean readOnly)java.sql.SavepointsetSavepoint()java.sql.SavepointsetSavepoint(java.lang.String name)private ClientSavepointsetSavepointX(ClientSavepoint savepoint)voidsetSchema(java.lang.String schemaName)Set the default schema for the Connection.voidsetTransactionIsolation(int level)private voidsetTransactionIsolationX(int level)Set the transaction isolation level as specified.voidsetTypeMap(java.util.Map map)voidsetXAState(int state)protected abstract booleansupportsSessionDataCaching()Finds out if the underlaying database connection supports session data caching.booleantransactionInProgress()Check if there are uncommitted operations in the current transaction that prevent us from closing the connection.private inttranslateIsolation(java.lang.String isolationStr)Translates the isolation level from a SQL string to the JDBC int valuebooleanwillAutoCommitGenerateFlow()(package private) voidwriteAutoCommit()private voidwriteCloseStatements()(package private) voidwriteCommit()abstract voidwriteCommitSubstitute_()abstract voidwriteLocalCommit_()abstract voidwriteLocalRollback_()abstract voidwriteLocalXACommit_()abstract voidwriteLocalXARollback_()abstract voidwriteLocalXAStart_()private voidwriteRollback()voidwriteTransactionStart(ClientStatement statement)protected abstract voidwriteXACommit_()protected abstract voidwriteXARollback_()protected abstract voidwriteXATransactionStart(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_ASSOCIATEDThis 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_ASSOCIATEDIn 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:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
createStatement
public java.sql.Statement createStatement() throws java.sql.SQLException- Specified by:
createStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException- Specified by:
prepareStatementin 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:
prepareCallin 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:
nativeSQLin 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:
setAutoCommitin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getAutoCommit
public boolean getAutoCommit() throws java.sql.SQLException- Specified by:
getAutoCommitin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
commit
public void commit() throws java.sql.SQLException- Specified by:
commitin 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:
rollbackin 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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
checkForTransactionInProgress
void checkForTransactionInProgress() throws SqlExceptionCheck 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:
trueif 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:
isClosedin interfacejava.sql.Connection
-
isClosedX
public boolean isClosedX()
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws java.sql.SQLException- Specified by:
setTransactionIsolationin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setTransactionIsolationX
private void setTransactionIsolationX(int level) throws SqlExceptionSet 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:
trueif 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:
getTransactionIsolationin 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.SQLExceptionReturns 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:
getWarningsin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
clearWarnings
public void clearWarnings() throws java.sql.SQLException- Specified by:
clearWarningsin 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:
getMetaDatain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws java.sql.SQLException- Specified by:
setReadOnlyin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
isReadOnly
public boolean isReadOnly() throws java.sql.SQLException- Specified by:
isReadOnlyin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setCatalog
public void setCatalog(java.lang.String catalog) throws java.sql.SQLException- Specified by:
setCatalogin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getCatalog
public java.lang.String getCatalog() throws java.sql.SQLException- Specified by:
getCatalogin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createStatement
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException- Specified by:
createStatementin 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:
prepareStatementin 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:
prepareCallin 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:
getTypeMapin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setTypeMap
public void setTypeMap(java.util.Map map) throws java.sql.SQLException- Specified by:
setTypeMapin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setHoldability
public void setHoldability(int holdability) throws java.sql.SQLException- Specified by:
setHoldabilityin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getHoldability
public int getHoldability() throws java.sql.SQLException- Specified by:
getHoldabilityin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException- Specified by:
setSavepointin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException- Specified by:
setSavepointin 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:
rollbackin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
releaseSavepoint
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException- Specified by:
releaseSavepointin 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:
createStatementin 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:
prepareStatementin 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:
prepareCallin 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:
prepareStatementin 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:
prepareStatementin 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:
prepareStatementin 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:
completeLocalCommitin 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:
completeLocalRollbackin 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:
completeAbnormalUnitOfWorkin interfaceConnectionCallbackInterface
-
completeAbnormalUnitOfWork
public void completeAbnormalUnitOfWork(UnitOfWorkListener uwl)
Rollback the UnitOfWorkListener specifically.- Specified by:
completeAbnormalUnitOfWorkin interfaceConnectionCallbackInterface- Parameters:
uwl- The UnitOfWorkListener to be rolled back.
-
completeChainBreakingDisconnect
public void completeChainBreakingDisconnect()
- Specified by:
completeChainBreakingDisconnectin interfaceConnectionCallbackInterface
-
completeSqlca
public void completeSqlca(Sqlca sqlca)
- Specified by:
completeSqlcain interfaceConnectionCallbackInterface
-
completePiggyBackIsolation
public void completePiggyBackIsolation(int pbIsolation)
Description copied from interface:ConnectionCallbackInterfaceCompletes piggy-backing of the new current isolation level by updating the cached copy in am.Connection.- Specified by:
completePiggyBackIsolationin 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:ConnectionCallbackInterfaceCompletes piggy-backing of the new current schema by updating the cached copy in am.Connection.- Specified by:
completePiggyBackSchemain 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.SQLExceptionConstructs an object that implements theClobinterface. The object returned initially contains no data.- Specified by:
createClobin interfacejava.sql.Connection- Returns:
- An object that implements the
Clobinterface - Throws:
java.sql.SQLException- if an object that implements theClobinterface can not be constructed.
-
createBlob
public java.sql.Blob createBlob() throws java.sql.SQLExceptionConstructs an object that implements theBlobinterface. The object returned initially contains no data.- Specified by:
createBlobin interfacejava.sql.Connection- Returns:
- An object that implements the
Blobinterface - 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.SQLExceptionGet the name of the current schema.- Specified by:
getSchemain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setSchema
public void setSchema(java.lang.String schemaName) throws java.sql.SQLExceptionSet the default schema for the Connection.- Specified by:
setSchemain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
abort
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException- Specified by:
abortin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws java.sql.SQLException- Specified by:
getNetworkTimeoutin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setNetworkTimeout
public void setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds) throws java.sql.SQLException- Specified by:
setNetworkTimeoutin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
-