com.ibm.as400.access
Class AS400JDBCXAConnection
java.lang.Object
|
+--com.ibm.as400.access.AS400JDBCPooledConnection
|
+--com.ibm.as400.access.AS400JDBCXAConnection
- All Implemented Interfaces:
- javax.sql.PooledConnection, javax.sql.XAConnection
- public class AS400JDBCXAConnection
- extends AS400JDBCPooledConnection
- implements javax.sql.XAConnection
The AS400JDBCXACConnection class represents a pooled connection
object that provides hooks for connection pool management and
XA resource management.
Because transaction boundaries are controlled by a
transaction manager, the caller cannot explicitly commit
or rollback on connections pooled by this object. In addition,
auto commit is initialized to false and cannot be set to true.
This support is only available when connecting to servers running OS/400 V5R1 or later.
The following example creates an AS400JDBCXAConnection object
that can be used to manage XA transactions.
// Create an XA data source for making the XA connection.
AS400JDBCXADataSource xaDataSource = new AS400JDBCXADataSource("myAS400");
xaDataSource.setUser("muUser");
xaDataSource.setPassword("myPasswd");
// Get an XAConnection and get the associated XAResource.
// This provides access to the resource manager.
XAConnection xaConnection = xaDataSource.getXAConnection();
XAResource xaResource = xaConnection.getXAResource();
// ... work with the XA resource.
// Close the XA connection when done. This implicitly
// closes the XA resource.
xaConnection.close();
- See Also:
AS400JDBCXADataSource
,
AS400JDBCXAResource
Method Summary |
javax.transaction.xa.XAResource |
getXAResource()
Returns the XA resource associated with this connection. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.sql.PooledConnection |
addConnectionEventListener, close, getConnection, removeConnectionEventListener |
getXAResource
public javax.transaction.xa.XAResource getXAResource()
throws java.sql.SQLException
- Returns the XA resource associated with this connection.
This implicitly opens the resource the first time it is
called.
- Specified by:
getXAResource
in interface javax.sql.XAConnection
- Returns:
- The XA resource.
- Throws:
java.sql.SQLException
- If an error occurs.