org.apache.derby.jdbc
Class EmbedXAConnection

java.lang.Object
  extended by org.apache.derby.jdbc.EmbedPooledConnection
      extended by org.apache.derby.jdbc.EmbedXAConnection
All Implemented Interfaces:
javax.sql.PooledConnection, javax.sql.XAConnection, BrokeredConnectionControl
Direct Known Subclasses:
EmbedXAConnection40

 class EmbedXAConnection
extends EmbedPooledConnection
implements javax.sql.XAConnection


Field Summary
private  EmbedXAResource xaRes
           
 
Fields inherited from class org.apache.derby.jdbc.EmbedPooledConnection
currentConnectionHandle, dataSource, defaultIsolationLevel, isActive, realConnection
 
Constructor Summary
EmbedXAConnection(EmbeddedDataSource ds, ResourceAdapter ra, java.lang.String u, java.lang.String p, boolean requestPassword)
           
 
Method Summary
 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 transaction
 java.sql.CallableStatement wrapStatement(java.sql.CallableStatement cs, java.lang.String sql)
          Wrap and control a PreparedStatement
 java.sql.PreparedStatement wrapStatement(java.sql.PreparedStatement ps, java.lang.String sql, java.lang.Object generatedKeys)
          Wrap and control a PreparedStatement
 java.sql.Statement wrapStatement(java.sql.Statement s)
          Wrap and control a Statement
 
Methods inherited from class org.apache.derby.jdbc.EmbedPooledConnection
addConnectionEventListener, checkActive, close, closingConnection, getLanguageConnection, getNewCurrentConnectionHandle, getPassword, getUsername, isIsolationLevelSetUsingSQLorJDBC, notifyError, notifyException, onStatementClose, onStatementErrorOccurred, openRealConnection, removeConnectionEventListener, 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 Detail

xaRes

private EmbedXAResource xaRes
Constructor Detail

EmbedXAConnection

EmbedXAConnection(EmbeddedDataSource 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 interface BrokeredConnectionControl
Overrides:
isInGlobalTransaction in class EmbedPooledConnection
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 interface javax.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 interface BrokeredConnectionControl
Overrides:
checkAutoCommit in class EmbedPooledConnection
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 interface BrokeredConnectionControl
Overrides:
checkHoldCursors in class EmbedPooledConnection
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 interface BrokeredConnectionControl
Overrides:
checkSavepoint in class EmbedPooledConnection
Throws:
java.sql.SQLException

checkRollback

public void checkRollback()
                   throws java.sql.SQLException
Allow control over calling rollback.

Specified by:
checkRollback in interface BrokeredConnectionControl
Overrides:
checkRollback in class EmbedPooledConnection
Throws:
java.sql.SQLException

checkCommit

public void checkCommit()
                 throws java.sql.SQLException
Allow control over calling commit.

Specified by:
checkCommit in interface BrokeredConnectionControl
Overrides:
checkCommit in class EmbedPooledConnection
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 interface BrokeredConnectionControl
Overrides:
checkClose in class EmbedPooledConnection
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 interface javax.sql.PooledConnection
Overrides:
getConnection in class EmbedPooledConnection
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 interface BrokeredConnectionControl
Overrides:
wrapStatement in class EmbedPooledConnection
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 interface BrokeredConnectionControl
Overrides:
wrapStatement in class EmbedPooledConnection
Parameters:
ps - PreparedStatment to be wrapped
sql - String
generatedKeys - 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 interface BrokeredConnectionControl
Overrides:
wrapStatement in class EmbedPooledConnection
Parameters:
cs - CallableStatment to be wrapped
sql - 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 interface BrokeredConnectionControl
Overrides:
getRealConnection in class EmbedPooledConnection
Throws:
java.sql.SQLException

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.