ca.idms.jdbc
Class IdmsXAConnection

java.lang.Object
  extended by ca.idms.io.TraceObject
      extended by ca.idms.jdbc.IdmsJdbcObject
          extended by ca.idms.jdbc.IdmsPooledConnection
              extended by ca.idms.jdbc.IdmsXAConnection
All Implemented Interfaces:
Trace, SQLState, ca.idms.xa.IdmsXAListener, javax.sql.PooledConnection, javax.sql.XAConnection

public class IdmsXAConnection
extends IdmsPooledConnection
implements javax.sql.XAConnection, ca.idms.xa.IdmsXAListener

IDMS two phase connection.

Version:
1.10, 06/21/05
Author:
Dave Ross

Field Summary
 
Fields inherited from class ca.idms.jdbc.IdmsJdbcObject
FAKE_METHODS, FAKE_SUPPORT, fakeSupport, MESSAGES
 
Fields inherited from class ca.idms.io.TraceObject
exclude, EXCLUDE, FALSE, include, INCLUDE, logWriter, PREFIX, PROPERTIES_FILE, PROPERTIES_KEY, snap, SNAP, SNAP_BYTES, SNAP_NATIVE, SNAP_OBJECT, SNAP_SQL, snapBytes, snapNative, snapObject, snapSql, stub, trace, TRACE, TRACE_FILE, TRACE_LIFE, TRACE_NATIVE, TRACE_PRODUCT, traceLife, traceNative, traceStream, TRUE
 
Fields inherited from interface ca.idms.qcli.SQLState
SQL_00000, SQL_01000, SQL_01004, SQL_07001, SQL_07009, SQL_08001, SQL_08002, SQL_08003, SQL_08004, SQL_08006, SQL_08007, SQL_0A000, SQL_21000, SQL_22000, SQL_22001, SQL_22003, SQL_22005, SQL_22007, SQL_24000, SQL_25000, SQL_3C000, SQL_40000, SQL_42000, SQL_HY000, SQL_HY004, SQL_HY009, SQL_HY010, SQL_HY024, SQL_HY106, SQL_HYC00
 
Method Summary
 void close()
          Removes reference to the XAResource and closes the PooledConnection.
 void connectionErrorOccurred(javax.transaction.xa.XAException e)
          Notifies ConnectionEvent listeners that a connection error has occurred.
 NativeMessage createNativeMessage()
          Creates the native message buffer for start and end.
 ca.idms.dsi.Sqlsid getSessionId()
          Gets the current DSI session id.
 javax.transaction.xa.XAResource getXAResource()
           
 boolean isStartAllowed()
          Checks if start is allowed.
 void notifyError(java.sql.SQLException ex, int rc)
          Overrides IdmsPooledConnection.notifyError(java.sql.SQLException, int).
 void transactionEnded(ca.idms.dsi.Sqlsid sid, int flags)
          Sets the current session to the local transaction.
 void transactionStarted(ca.idms.dsi.Sqlsid sid, int flags)
          Sets the current session to the global transaction.
 
Methods inherited from class ca.idms.jdbc.IdmsPooledConnection
addConnectionEventListener, addStatementEventListener, get, getConnection, notifyClosed, notifyStatementClosed, notifyStatementError, removeConnectionEventListener, removeStatementEventListener
 
Methods inherited from class ca.idms.jdbc.IdmsJdbcObject
clearWarnings, getWarnings, hasCursor, hasUpdate, isStarted, isSuspended, isWrapperFor, notifyStatementError, unwrap
 
Methods inherited from class ca.idms.io.TraceObject
finalize, getBoolean, getClasses, getInteger, getProperty, listProperties, message, parseList, print, print, print, println, println, snap, snap, snap, snap, snap, snap, snap, toHex, toHex, toHex, toHex, toHex, toString, trace, trace, trace, trace, trace, trace, traceEntry, unloadProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.sql.PooledConnection
addConnectionEventListener, addStatementEventListener, getConnection, removeConnectionEventListener, removeStatementEventListener
 

Method Detail

getXAResource

public javax.transaction.xa.XAResource getXAResource()
                                              throws java.sql.SQLException
Specified by:
getXAResource in interface javax.sql.XAConnection
Returns:
an IDMS XA Transaction interface object.
Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
Removes reference to the XAResource and closes the PooledConnection.

Specified by:
close in interface javax.sql.PooledConnection
Overrides:
close in class IdmsPooledConnection
Throws:
java.sql.SQLException - (not really)

notifyError

public void notifyError(java.sql.SQLException ex,
                        int rc)
Overrides IdmsPooledConnection.notifyError(java.sql.SQLException, int). Closes the IdmsXAResource and notifies listeners that a connection error has occurred.

Overrides:
notifyError in class IdmsPooledConnection
Parameters:
ex - SQLException that will be thrown to the application
rc - QcliException reason code or 0 if an IOException
See Also:
IdmsPooledConnection.notifyError(java.sql.SQLException, int)

createNativeMessage

public NativeMessage createNativeMessage()
Creates the native message buffer for start and end.

Specified by:
createNativeMessage in interface ca.idms.xa.IdmsXAListener
Returns:
an empty SQLCA

getSessionId

public ca.idms.dsi.Sqlsid getSessionId()
Gets the current DSI session id.

Specified by:
getSessionId in interface ca.idms.xa.IdmsXAListener
Returns:
the SQLSID for the current session, null if closed

isStartAllowed

public boolean isStartAllowed()
Checks if start is allowed.

Specified by:
isStartAllowed in interface ca.idms.xa.IdmsXAListener
Returns:
true if so, false otherwise The IdmsXAResource object invokes this method before attempting to execute IdmsXAResource.start(javax.transaction.xa.Xid, int). This methods checks that the current session is the local transaction and that there are no pending updates.

transactionStarted

public void transactionStarted(ca.idms.dsi.Sqlsid sid,
                               int flags)
                        throws javax.transaction.xa.XAException
Sets the current session to the global transaction. The IdmsXAResource object invokes this method after successfully executing IdmsXAResource.start(javax.transaction.xa.Xid, int). If flags contains TMRESUME the session is retrieved from the suspended sessions table, otherwise a new IdmsSession object is created. In either case the session will be set for the connection and all existing Statement obects.

Specified by:
transactionStarted in interface ca.idms.xa.IdmsXAListener
Parameters:
sid - SQL session identifier returned from XCLI.
flags - XAResource.end flags
Throws:
javax.transaction.xa.XAException - if suspended session not found for TMRESUME

transactionEnded

public void transactionEnded(ca.idms.dsi.Sqlsid sid,
                             int flags)
                      throws javax.transaction.xa.XAException
Sets the current session to the local transaction. The IdmsXAResource object invokes this method after successfully executing IdmsXAResource.end(javax.transaction.xa.Xid, int). If flags contains TMRSUSPEND the session is saved in the suspended sessions table. The local transaction session is set for the connection and all existing Statement obects.

Specified by:
transactionEnded in interface ca.idms.xa.IdmsXAListener
Parameters:
sid - SQL session identifier returned from XCLI.
flags - XAResource.end flags
Throws:
javax.transaction.xa.XAException - if XCLI did not return the local session

connectionErrorOccurred

public void connectionErrorOccurred(javax.transaction.xa.XAException e)
Notifies ConnectionEvent listeners that a connection error has occurred. The IdmsXAResource object invokes this method when a connection error occurs while processing a XA request. Since the connection is no longer usable, the current session is not changed.

Specified by:
connectionErrorOccurred in interface ca.idms.xa.IdmsXAListener
Parameters:
e - the XAException


Copyright © 2009 CA, All rights reserved