public class AS400JDBCXAResource
extends java.lang.Object
implements javax.transaction.xa.XAResource
This support is only available when connecting to systems running OS/400 V5R1 or later, or IBM i.
The following example creates an AS400JDBCXAResource object that can be used to work with the XA resource manager.
// Create an XA data source for making the XA connection.
AS400JDBCXADataSource xaDataSource = new AS400JDBCXADataSource("myAS400");
xaDataSource.setUser("myUser");
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();
AS400JDBCXAConnection,
AS400JDBCXADataSource| Modifier and Type | Method and Description |
|---|---|
void |
commit(javax.transaction.xa.Xid xid,
boolean onePhase)
Commits a global transaction.
|
void |
end(javax.transaction.xa.Xid xid,
int flags)
Ends the work performed on behalf of a transaction branch.
|
void |
forget(javax.transaction.xa.Xid xid)
Tells the resource manager to forget about a heuristically completed
transaction branch.
|
int |
getTransactionTimeout()
Returns the current transaction timeout value.
|
boolean |
isSameRM(javax.transaction.xa.XAResource xaResource)
Indicates if the resource manager represented by this XA resource
is the same resource manager represented by the specified XA resource.
|
int |
prepare(javax.transaction.xa.Xid xid)
Prepares for a transaction commit.
|
javax.transaction.xa.Xid[] |
recover(int flags)
Recovers a list of prepared transaction branches from the
resource manager.
|
void |
rollback(javax.transaction.xa.Xid xid)
Rolls back a transaction branch.
|
void |
setLockWait(int lockWait)
Specifies the number of seconds that the system will wait on any lock request during this transaction.
|
boolean |
setTransactionTimeout(int transactionTimeout)
Sets the current transaction timeout value.
|
void |
start(javax.transaction.xa.Xid xid,
int flags)
Starts the work on behalf of a transaction branch.
|
java.lang.String |
toString()
Returns the string representation of the XA resource.
|
public void commit(javax.transaction.xa.Xid xid,
boolean onePhase)
throws javax.transaction.xa.XAException
commit in interface javax.transaction.xa.XAResourcexid - The global transaction identifier.onePhase - true if the resource manager should use a one-phase
commit protocol to commit the work; false otherwise.javax.transaction.xa.XAException - If an error occurs.public void end(javax.transaction.xa.Xid xid,
int flags)
throws javax.transaction.xa.XAException
end in interface javax.transaction.xa.XAResourcexid - The global transaction identifier. This must correspond
to the global transaction identifier previously passed
to start().flags - The flags. Possible values are:
javax.transaction.xa.XAException - If an error occurs.public void forget(javax.transaction.xa.Xid xid)
throws javax.transaction.xa.XAException
forget in interface javax.transaction.xa.XAResourcexid - The global transaction identifier.javax.transaction.xa.XAException - If an error occurs.public int getTransactionTimeout()
throws javax.transaction.xa.XAException
getTransactionTimeout in interface javax.transaction.xa.XAResourcejavax.transaction.xa.XAException - If an error occurs.public boolean isSameRM(javax.transaction.xa.XAResource xaResource)
throws javax.transaction.xa.XAException
isSameRM in interface javax.transaction.xa.XAResourcexaResource - The XA resource.javax.transaction.xa.XAException - If an error occurs.public int prepare(javax.transaction.xa.Xid xid)
throws javax.transaction.xa.XAException
prepare in interface javax.transaction.xa.XAResourcexid - The global transaction identifier.javax.transaction.xa.XAException - If an error occurs.public javax.transaction.xa.Xid[] recover(int flags)
throws javax.transaction.xa.XAException
recover in interface javax.transaction.xa.XAResourceflags - The flags. Possible values are:
javax.transaction.xa.XAException - If an error occurs.public void rollback(javax.transaction.xa.Xid xid)
throws javax.transaction.xa.XAException
rollback in interface javax.transaction.xa.XAResourcexid - The global transaction identifier.javax.transaction.xa.XAException - If an error occurs.public boolean setTransactionTimeout(int transactionTimeout)
throws javax.transaction.xa.XAException
setTransactionTimeout in interface javax.transaction.xa.XAResourcetransactionTimeout - The current transaction timeout value in seconds,
or 0 to reset the timeout value to the default. The transaction timeout
will be set the next time start() is called.javax.transaction.xa.XAException - If an error occurs.public void start(javax.transaction.xa.Xid xid,
int flags)
throws javax.transaction.xa.XAException
start in interface javax.transaction.xa.XAResourcexid - The global transaction identifier.flags - The flags. Possible values are:
javax.transaction.xa.XAException - If an error occurs.public void setLockWait(int lockWait)
throws java.sql.SQLException
lockWait - The time in seconds to wait.java.sql.SQLException - If a database error occurs.public java.lang.String toString()
toString in class java.lang.Object