Package org.apache.derby.jdbc
Class EmbedXAConnection
- java.lang.Object
-
- org.apache.derby.jdbc.EmbedPooledConnection
-
- org.apache.derby.jdbc.EmbedXAConnection
-
- All Implemented Interfaces:
javax.sql.PooledConnection,javax.sql.XAConnection,BrokeredConnectionControl
class EmbedXAConnection extends EmbedPooledConnection implements javax.sql.XAConnection
-
-
Field Summary
Fields Modifier and Type Field Description private EmbedXAResourcexaRes-
Fields inherited from class org.apache.derby.jdbc.EmbedPooledConnection
currentConnectionHandle, dataSource, defaultIsolationLevel, isActive, realConnection
-
-
Constructor Summary
Constructors Constructor Description EmbedXAConnection(BasicEmbeddedDataSource40 ds, ResourceAdapter ra, java.lang.String u, java.lang.String p, boolean requestPassword)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckAutoCommit(boolean autoCommit)Allow control over setting auto commit mode.voidcheckClose()Check if the brokered connection can be closed.voidcheckCommit()Allow control over calling commit.intcheckHoldCursors(int holdability, boolean downgrade)Are held cursors allowed.voidcheckRollback()Allow control over calling rollback.voidcheckSavepoint()Allow control over creating a Savepoint (JDBC 3.0)java.sql.ConnectiongetConnection()Create an object handle for a database connection.EngineConnectiongetRealConnection()Override getRealConnection to create a a local connection when we are not associated with an XA transaction.javax.transaction.xa.XAResourcegetXAResource()private booleanisGlobal()Check if this connection is part of a global XA transaction.booleanisInGlobalTransaction()Is this a global transactionjava.sql.CallableStatementwrapStatement(java.sql.CallableStatement cs, java.lang.String sql)Wrap and control a PreparedStatementjava.sql.PreparedStatementwrapStatement(java.sql.PreparedStatement ps, java.lang.String sql, java.lang.Object generatedKeys)Wrap and control a PreparedStatementjava.sql.StatementwrapStatement(java.sql.Statement s)Wrap and control a Statement-
Methods 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
-
-
-
-
Field Detail
-
xaRes
private EmbedXAResource xaRes
-
-
Constructor Detail
-
EmbedXAConnection
EmbedXAConnection(BasicEmbeddedDataSource40 ds, ResourceAdapter ra, java.lang.String u, java.lang.String p, boolean requestPassword) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-
Method Detail
-
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:
BrokeredConnectionControl.isInGlobalTransaction()
-
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
public final javax.transaction.xa.XAResource getXAResource() throws java.sql.SQLException- Specified by:
getXAResourcein interfacejavax.sql.XAConnection- Throws:
java.sql.SQLException
-
checkAutoCommit
public void checkAutoCommit(boolean autoCommit) throws java.sql.SQLExceptionAllow control over setting auto commit mode.- Specified by:
checkAutoCommitin interfaceBrokeredConnectionControl- Overrides:
checkAutoCommitin classEmbedPooledConnection- Throws:
java.sql.SQLException
-
checkHoldCursors
public int checkHoldCursors(int holdability, boolean downgrade) throws java.sql.SQLExceptionAre 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 classEmbedPooledConnectiondowngrade- true to downgrade the holdability, false to throw an exception.- Throws:
java.sql.SQLException
-
checkSavepoint
public void checkSavepoint() throws java.sql.SQLExceptionAllow control over creating a Savepoint (JDBC 3.0)- Specified by:
checkSavepointin interfaceBrokeredConnectionControl- Overrides:
checkSavepointin classEmbedPooledConnection- Throws:
java.sql.SQLException
-
checkRollback
public void checkRollback() throws java.sql.SQLExceptionAllow control over calling rollback.- Specified by:
checkRollbackin interfaceBrokeredConnectionControl- Overrides:
checkRollbackin classEmbedPooledConnection- Throws:
java.sql.SQLException
-
checkCommit
public void checkCommit() throws java.sql.SQLExceptionAllow control over calling commit.- Specified by:
checkCommitin interfaceBrokeredConnectionControl- Overrides:
checkCommitin classEmbedPooledConnection- Throws:
java.sql.SQLException
-
checkClose
public void checkClose() throws java.sql.SQLExceptionDescription copied from interface:BrokeredConnectionControlCheck if the brokered connection can be closed.- Specified by:
checkClosein interfaceBrokeredConnectionControl- Overrides:
checkClosein classEmbedPooledConnection- Throws:
java.sql.SQLException- if it is not allowed to call close on the brokered connection- See Also:
BrokeredConnectionControl.checkClose()
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLExceptionDescription copied from class:EmbedPooledConnectionCreate an object handle for a database connection.- Specified by:
getConnectionin interfacejavax.sql.PooledConnection- Overrides:
getConnectionin classEmbedPooledConnection- Returns:
- a Connection object
- Throws:
java.sql.SQLException- - if a database-access error occurs.
-
wrapStatement
public java.sql.Statement wrapStatement(java.sql.Statement s) throws java.sql.SQLExceptionWrap and control a Statement- Specified by:
wrapStatementin interfaceBrokeredConnectionControl- Overrides:
wrapStatementin classEmbedPooledConnection- Throws:
java.sql.SQLException
-
wrapStatement
public java.sql.PreparedStatement wrapStatement(java.sql.PreparedStatement ps, java.lang.String sql, java.lang.Object generatedKeys) throws java.sql.SQLExceptionWrap 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:
java.sql.SQLException
-
wrapStatement
public java.sql.CallableStatement wrapStatement(java.sql.CallableStatement cs, java.lang.String sql) throws java.sql.SQLExceptionWrap and control a PreparedStatement- Specified by:
wrapStatementin interfaceBrokeredConnectionControl- Overrides:
wrapStatementin classEmbedPooledConnection- Parameters:
cs- CallableStatment to be wrappedsql- String- Returns:
- returns the wrapped CallableStatement
- Throws:
java.sql.SQLException
-
getRealConnection
public EngineConnection getRealConnection() throws java.sql.SQLException
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:
java.sql.SQLException
-
-