Package org.apache.derby.jdbc
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 org.apache.derby.jdbc.EmbedPooledConnection
currentConnectionHandle, dataSource, defaultIsolationLevel, isActive, realConnection
-
Constructor Summary
ConstructorsConstructorDescriptionEmbedXAConnection
(BasicEmbeddedDataSource40 ds, ResourceAdapter ra, String u, String p, boolean requestPassword) -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkAutoCommit
(boolean autoCommit) Allow control over setting auto commit mode.void
Check if the brokered connection can be closed.void
Allow control over calling commit.int
checkHoldCursors
(int holdability, boolean downgrade) Are held cursors allowed.void
Allow control over calling rollback.void
Allow 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 XAResource
private boolean
isGlobal()
Check if this connection is part of a global XA transaction.boolean
Is 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 org.apache.derby.jdbc.EmbedPooledConnection
addConnectionEventListener, addStatementEventListener, checkActive, close, closingConnection, getLanguageConnection, getNewCurrentConnectionHandle, getPassword, getUsername, isActive, isIsolationLevelSetUsingSQLorJDBC, notifyError, notifyException, onStatementClose, onStatementErrorOccurred, openRealConnection, removeConnectionEventListener, removeStatementEventListener, resetIsolationLevelFlag, resetRealConnection, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface javax.sql.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:BrokeredConnectionControl
Is this a global transaction- Specified by:
isInGlobalTransaction
in interfaceBrokeredConnectionControl
- Overrides:
isInGlobalTransaction
in 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:
true
if the transaction is global,false
if the transaction is local
-
getXAResource
- Specified by:
getXAResource
in interfaceXAConnection
- Throws:
SQLException
-
checkAutoCommit
Allow control over setting auto commit mode.- Specified by:
checkAutoCommit
in interfaceBrokeredConnectionControl
- Overrides:
checkAutoCommit
in 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:
checkHoldCursors
in interfaceBrokeredConnectionControl
- Overrides:
checkHoldCursors
in 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:
checkSavepoint
in interfaceBrokeredConnectionControl
- Overrides:
checkSavepoint
in classEmbedPooledConnection
- Throws:
SQLException
-
checkRollback
Allow control over calling rollback.- Specified by:
checkRollback
in interfaceBrokeredConnectionControl
- Overrides:
checkRollback
in classEmbedPooledConnection
- Throws:
SQLException
-
checkCommit
Allow control over calling commit.- Specified by:
checkCommit
in interfaceBrokeredConnectionControl
- Overrides:
checkCommit
in classEmbedPooledConnection
- Throws:
SQLException
-
checkClose
Description copied from interface:BrokeredConnectionControl
Check if the brokered connection can be closed.- Specified by:
checkClose
in interfaceBrokeredConnectionControl
- Overrides:
checkClose
in classEmbedPooledConnection
- Throws:
SQLException
- if it is not allowed to call close on the brokered connection- See Also:
-
getConnection
Description copied from class:EmbedPooledConnection
Create an object handle for a database connection.- Specified by:
getConnection
in interfacePooledConnection
- Overrides:
getConnection
in classEmbedPooledConnection
- Returns:
- a Connection object
- Throws:
SQLException
- - if a database-access error occurs.
-
wrapStatement
Wrap and control a Statement- Specified by:
wrapStatement
in interfaceBrokeredConnectionControl
- Overrides:
wrapStatement
in classEmbedPooledConnection
- Throws:
SQLException
-
wrapStatement
public PreparedStatement wrapStatement(PreparedStatement ps, String sql, Object generatedKeys) throws SQLException Wrap and control a PreparedStatement- Specified by:
wrapStatement
in interfaceBrokeredConnectionControl
- Overrides:
wrapStatement
in classEmbedPooledConnection
- Parameters:
ps
- PreparedStatment to be wrappedsql
- StringgeneratedKeys
- Object- Returns:
- returns the wrapped PreparedStatement
- Throws:
SQLException
-
wrapStatement
Wrap and control a PreparedStatement- Specified by:
wrapStatement
in interfaceBrokeredConnectionControl
- Overrides:
wrapStatement
in 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:
getRealConnection
in interfaceBrokeredConnectionControl
- Overrides:
getRealConnection
in classEmbedPooledConnection
- Throws:
SQLException
-