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 EmbedXAResource
xaRes
-
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 void
checkAutoCommit(boolean autoCommit)
Allow control over setting auto commit mode.void
checkClose()
Check if the brokered connection can be closed.void
checkCommit()
Allow control over calling commit.int
checkHoldCursors(int holdability, boolean downgrade)
Are held cursors allowed.void
checkRollback()
Allow control over calling rollback.void
checkSavepoint()
Allow control over creating a Savepoint (JDBC 3.0)java.sql.Connection
getConnection()
Create an object handle for a database connection.EngineConnection
getRealConnection()
Override getRealConnection to create a a local connection when we are not associated with an XA transaction.javax.transaction.xa.XAResource
getXAResource()
private boolean
isGlobal()
Check if this connection is part of a global XA transaction.boolean
isInGlobalTransaction()
Is this a global transactionjava.sql.CallableStatement
wrapStatement(java.sql.CallableStatement cs, java.lang.String sql)
Wrap and control a PreparedStatementjava.sql.PreparedStatement
wrapStatement(java.sql.PreparedStatement ps, java.lang.String sql, java.lang.Object generatedKeys)
Wrap and control a PreparedStatementjava.sql.Statement
wrapStatement(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: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:
BrokeredConnectionControl.isInGlobalTransaction()
-
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
public final javax.transaction.xa.XAResource getXAResource() throws java.sql.SQLException
- Specified by:
getXAResource
in interfacejavax.sql.XAConnection
- Throws:
java.sql.SQLException
-
checkAutoCommit
public void checkAutoCommit(boolean autoCommit) throws java.sql.SQLException
Allow control over setting auto commit mode.- Specified by:
checkAutoCommit
in interfaceBrokeredConnectionControl
- Overrides:
checkAutoCommit
in classEmbedPooledConnection
- Throws:
java.sql.SQLException
-
checkHoldCursors
public int checkHoldCursors(int holdability, boolean downgrade) throws java.sql.SQLException
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
downgrade
- true to downgrade the holdability, false to throw an exception.- Throws:
java.sql.SQLException
-
checkSavepoint
public void checkSavepoint() throws java.sql.SQLException
Allow control over creating a Savepoint (JDBC 3.0)- Specified by:
checkSavepoint
in interfaceBrokeredConnectionControl
- Overrides:
checkSavepoint
in classEmbedPooledConnection
- Throws:
java.sql.SQLException
-
checkRollback
public void checkRollback() throws java.sql.SQLException
Allow control over calling rollback.- Specified by:
checkRollback
in interfaceBrokeredConnectionControl
- Overrides:
checkRollback
in classEmbedPooledConnection
- Throws:
java.sql.SQLException
-
checkCommit
public void checkCommit() throws java.sql.SQLException
Allow control over calling commit.- Specified by:
checkCommit
in interfaceBrokeredConnectionControl
- Overrides:
checkCommit
in classEmbedPooledConnection
- Throws:
java.sql.SQLException
-
checkClose
public void checkClose() throws java.sql.SQLException
Description copied from interface:BrokeredConnectionControl
Check if the brokered connection can be closed.- Specified by:
checkClose
in interfaceBrokeredConnectionControl
- Overrides:
checkClose
in 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.SQLException
Description copied from class:EmbedPooledConnection
Create an object handle for a database connection.- Specified by:
getConnection
in interfacejavax.sql.PooledConnection
- Overrides:
getConnection
in 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.SQLException
Wrap and control a Statement- Specified by:
wrapStatement
in interfaceBrokeredConnectionControl
- Overrides:
wrapStatement
in 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.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:
java.sql.SQLException
-
wrapStatement
public java.sql.CallableStatement wrapStatement(java.sql.CallableStatement cs, java.lang.String sql) throws java.sql.SQLException
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:
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:
getRealConnection
in interfaceBrokeredConnectionControl
- Overrides:
getRealConnection
in classEmbedPooledConnection
- Throws:
java.sql.SQLException
-
-