tyrex.resource.jdbc.xa
Class ClientConnection

java.lang.Object
  extended bytyrex.resource.jdbc.xa.TyrexConnection
      extended bytyrex.resource.jdbc.xa.ClientConnection
All Implemented Interfaces:
java.sql.Connection

final class ClientConnection
extends TyrexConnection
implements java.sql.Connection

Encapsulates an application's view of an XA/pooled connection. The XA connection is managed by the application server through it's XAConnection interface. The underlying JDBC connection is a standard JDBC connection. The application's JDBC connection gives access to the underlying JDBC connection but is managed by the application server. The application is given an instance of this class and not the underlying connection directly.

Version:
1.0
Author:
Assaf Arkin
See Also:
XAConnectionImpl, XADataSourceImpl, Connection

Field Summary
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
(package private) ClientConnection(XAConnectionImpl xaConn, XADataSourceImpl xaDataSource, int clientId)
          Construct a new client connection to provide access to the underlying JDBC connection (underlying) on behalf of an XA/pooled connection (xaConn).
 
Method Summary
 void commit()
           
 boolean getAutoCommit()
           
protected  void internalClose()
          Method that actually closes the connection.
protected  java.sql.Connection internalGetUnderlyingConnection()
          Called to retrieve the underlying JDBC connection.
 boolean isClosed()
          Return true if the connection is closed.
protected  void notifyError(java.sql.SQLException except)
          Called when an exception is thrown by the underlying connection to determine whether the exception is critical or not.
 void rollback()
           
 void setAutoCommit(boolean autoCommit)
           
 java.lang.String toString()
          Called by XAConnectionImpl to terminate this connection by dissociating it from the underlying JDBC connection.
 
Methods inherited from class tyrex.resource.jdbc.xa.TyrexConnection
clearWarnings, close, createStatement, createStatement, createStatement, finalize, getCatalog, getHoldability, getMetaData, getTransactionIsolation, getTypeMap, getWarnings, isReadOnly, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, setCatalog, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMap
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.sql.Connection
clearWarnings, close, createStatement, createStatement, createStatement, getCatalog, getHoldability, getMetaData, getTransactionIsolation, getTypeMap, getWarnings, isReadOnly, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, setCatalog, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMap
 

Constructor Detail

ClientConnection

ClientConnection(XAConnectionImpl xaConn,
                 XADataSourceImpl xaDataSource,
                 int clientId)
Construct a new client connection to provide access to the underlying JDBC connection (underlying) on behalf of an XA/pooled connection (xaConn). The pooled connection is required to notify of connection closure and fatal errors.

Parameters:
xaConn - The XA/pooled connection that created this client connection
xaDataSource - the data source that created the xaConn
clientId - A unique identifier handed to us by XAConnection
Method Detail

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
Specified by:
setAutoCommit in interface java.sql.Connection
Overrides:
setAutoCommit in class TyrexConnection
Throws:
java.sql.SQLException

getAutoCommit

public boolean getAutoCommit()
                      throws java.sql.SQLException
Specified by:
getAutoCommit in interface java.sql.Connection
Overrides:
getAutoCommit in class TyrexConnection
Throws:
java.sql.SQLException

commit

public void commit()
            throws java.sql.SQLException
Specified by:
commit in interface java.sql.Connection
Overrides:
commit in class TyrexConnection
Throws:
java.sql.SQLException

rollback

public void rollback()
              throws java.sql.SQLException
Specified by:
rollback in interface java.sql.Connection
Overrides:
rollback in class TyrexConnection
Throws:
java.sql.SQLException

internalClose

protected void internalClose()
                      throws java.sql.SQLException
Description copied from class: TyrexConnection
Method that actually closes the connection.

Specified by:
internalClose in class TyrexConnection
Throws:
java.sql.SQLException - if there is a problem closing the connection
See Also:
TyrexConnection.close()

isClosed

public boolean isClosed()
Description copied from class: TyrexConnection
Return true if the connection is closed.

Specified by:
isClosed in interface java.sql.Connection
Specified by:
isClosed in class TyrexConnection
Returns:
true if the connection is closed.

toString

public java.lang.String toString()
Called by XAConnectionImpl to terminate this connection by dissociating it from the underlying JDBC connection. The application would call TyrexConnection.close() but XAConnectionImpl cannot, since pooled connection requirements will cause an inifinite loop. This method should not attempt to notify either a closure or fatal error, but rather throw an exception if it fails.


notifyError

protected void notifyError(java.sql.SQLException except)
Called when an exception is thrown by the underlying connection to determine whether the exception is critical or not. If the exception is critical, notifies the XA connection to forget about this connection.

Overrides:
notifyError in class TyrexConnection
Parameters:
except - The exception thrown by the underlying connection

internalGetUnderlyingConnection

protected java.sql.Connection internalGetUnderlyingConnection()
                                                       throws java.sql.SQLException
Called to retrieve the underlying JDBC connection. Actual JDBC operations are performed against it. Throws an SQLException if this connection has been closed.

Specified by:
internalGetUnderlyingConnection in class TyrexConnection
Returns:
the underlying connection
Throws:
java.sql.SQLException - if the connection cannot be retrieved.
See Also:
#getUnderlyingConnection


Original code is Copyright (c) 1999-2001, Intalio, Inc. All Rights Reserved. Contributions by MetaBoss team are Copyright (c) 2003-2005, Softaris Pty. Ltd. All Rights Reserved.