Class EmbedXAConnection
java.lang.Object
org.apache.derby.jdbc.EmbedPooledConnection
org.apache.derby.jdbc.EmbedXAConnection
- All Implemented Interfaces:
PooledConnection, XAConnection, BrokeredConnectionControl
-
Field Summary
FieldsFields inherited from class EmbedPooledConnection
currentConnectionHandle, dataSource, defaultIsolationLevel, isActive, realConnection -
Constructor Summary
ConstructorsConstructorDescriptionEmbedXAConnection(BasicEmbeddedDataSource40 ds, ResourceAdapter ra, String u, String p, boolean requestPassword) -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckAutoCommit(boolean autoCommit) Allow control over setting auto commit mode.voidCheck if the brokered connection can be closed.voidAllow control over calling commit.intcheckHoldCursors(int holdability, boolean downgrade) Are held cursors allowed.voidAllow control over calling rollback.voidAllow control over creating a Savepoint (JDBC 3.0)Create an object handle for a database connection.Override getRealConnection to create a a local connection when we are not associated with an XA transaction.final XAResourceprivate booleanisGlobal()Check if this connection is part of a global XA transaction.booleanIs this a global transactionwrapStatement(CallableStatement cs, String sql) Wrap and control a PreparedStatementwrapStatement(PreparedStatement ps, String sql, Object generatedKeys) Wrap and control a PreparedStatementWrap and control a StatementMethods inherited from class EmbedPooledConnection
addConnectionEventListener, addStatementEventListener, checkActive, close, closingConnection, getLanguageConnection, getNewCurrentConnectionHandle, getPassword, getUsername, isActive, isIsolationLevelSetUsingSQLorJDBC, notifyError, notifyException, onStatementClose, onStatementErrorOccurred, openRealConnection, removeConnectionEventListener, removeStatementEventListener, resetIsolationLevelFlag, resetRealConnection, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface PooledConnection
addConnectionEventListener, addStatementEventListener, close, removeConnectionEventListener, removeStatementEventListener
-
Field Details
-
xaRes
-
-
Constructor Details
-
EmbedXAConnection
EmbedXAConnection(BasicEmbeddedDataSource40 ds, ResourceAdapter ra, String u, String p, boolean requestPassword) throws SQLException - Throws:
SQLException
-
-
Method Details
-
isInGlobalTransaction
public boolean isInGlobalTransaction()Description copied from interface:BrokeredConnectionControlIs this a global transaction- Specified by:
isInGlobalTransactionin interfaceBrokeredConnectionControl- Overrides:
isInGlobalTransactionin classEmbedPooledConnection- Returns:
- true if this is a global XA transaction
- See Also:
-
isGlobal
private boolean isGlobal()Check if this connection is part of a global XA transaction.- Returns:
trueif the transaction is global,falseif the transaction is local
-
getXAResource
- Specified by:
getXAResourcein interfaceXAConnection- Throws:
SQLException
-
checkAutoCommit
Allow control over setting auto commit mode.- Specified by:
checkAutoCommitin interfaceBrokeredConnectionControl- Overrides:
checkAutoCommitin classEmbedPooledConnection- Throws:
SQLException
-
checkHoldCursors
Are held cursors allowed. If the connection is attached to a global transaction then downgrade the result set holdabilty to CLOSE_CURSORS_AT_COMMIT if downgrade is true, otherwise throw an exception. If the connection is in a local transaction then the passed in holdabilty is returned.- Specified by:
checkHoldCursorsin interfaceBrokeredConnectionControl- Overrides:
checkHoldCursorsin classEmbedPooledConnection- Parameters:
downgrade- true to downgrade the holdability, false to throw an exception.- Throws:
SQLException
-
checkSavepoint
Allow control over creating a Savepoint (JDBC 3.0)- Specified by:
checkSavepointin interfaceBrokeredConnectionControl- Overrides:
checkSavepointin classEmbedPooledConnection- Throws:
SQLException
-
checkRollback
Allow control over calling rollback.- Specified by:
checkRollbackin interfaceBrokeredConnectionControl- Overrides:
checkRollbackin classEmbedPooledConnection- Throws:
SQLException
-
checkCommit
Allow control over calling commit.- Specified by:
checkCommitin interfaceBrokeredConnectionControl- Overrides:
checkCommitin classEmbedPooledConnection- Throws:
SQLException
-
checkClose
Description copied from interface:BrokeredConnectionControlCheck if the brokered connection can be closed.- Specified by:
checkClosein interfaceBrokeredConnectionControl- Overrides:
checkClosein classEmbedPooledConnection- Throws:
SQLException- if it is not allowed to call close on the brokered connection- See Also:
-
getConnection
Description copied from class:EmbedPooledConnectionCreate an object handle for a database connection.- Specified by:
getConnectionin interfacePooledConnection- Overrides:
getConnectionin classEmbedPooledConnection- Returns:
- a Connection object
- Throws:
SQLException- - if a database-access error occurs.
-
wrapStatement
Wrap and control a Statement- Specified by:
wrapStatementin interfaceBrokeredConnectionControl- Overrides:
wrapStatementin classEmbedPooledConnection- Throws:
SQLException
-
wrapStatement
public PreparedStatement wrapStatement(PreparedStatement ps, String sql, Object generatedKeys) throws SQLException Wrap and control a PreparedStatement- Specified by:
wrapStatementin interfaceBrokeredConnectionControl- Overrides:
wrapStatementin classEmbedPooledConnection- Parameters:
ps- PreparedStatment to be wrappedsql- StringgeneratedKeys- Object- Returns:
- returns the wrapped PreparedStatement
- Throws:
SQLException
-
wrapStatement
Wrap and control a PreparedStatement- Specified by:
wrapStatementin interfaceBrokeredConnectionControl- Overrides:
wrapStatementin classEmbedPooledConnection- Parameters:
cs- CallableStatment to be wrappedsql- String- Returns:
- returns the wrapped CallableStatement
- Throws:
SQLException
-
getRealConnection
Override getRealConnection to create a a local connection when we are not associated with an XA transaction. This can occur if the application has a Connection object (conn) and the following sequence occurs. conn = xac.getConnection(); xac.start(xid, ...) // do work with conn xac.end(xid, ...); // do local work with conn // need to create new connection here.- Specified by:
getRealConnectionin interfaceBrokeredConnectionControl- Overrides:
getRealConnectionin classEmbedPooledConnection- Throws:
SQLException
-