public class JDBCXID
extends java.lang.Object
implements javax.transaction.xa.Xid
// Example usage:
JDBCXADataSource ds = new JDBCXADataSource();
ds.setUser(user);
ds.setPassword(password);
ds.setUrl(jdbcUrl);
XAConnection xaCon = ds.getConnection();
Connection con = xaCon.getConnection();
Xid xid = JDBCXID.getUniqueXid((int)Thread.currentThread().getId());
XAResource xaRes = xaCon.getXAResource();
// Start the transaction.
System.out.println("Starting XA transaction with xid = " + xid.toString());
xaRes.setTransactionTimeout(0);
xaRes.start(xid,XAResource.TMNOFLAGS);
// Do work here ....
// Commit the transaction.
xaRes.end(xid,XAResource.TMSUCCESS);
xaRes.commit(xid,true);
// Cleanup.
con.close();
xaCon.close();
| Constructor and Description |
|---|
JDBCXID(int formatID,
byte[] txID,
byte[] txBranch) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object other) |
byte[] |
getBranchQualifier() |
int |
getFormatId() |
byte[] |
getGlobalTransactionId() |
static javax.transaction.xa.Xid |
getUniqueXid(int threadId)
Retrieves a randomly generated JDBCXID.
|
int |
hashCode() |
java.lang.String |
toString() |
public int getFormatId()
getFormatId in interface javax.transaction.xa.Xidpublic byte[] getGlobalTransactionId()
getGlobalTransactionId in interface javax.transaction.xa.Xidpublic byte[] getBranchQualifier()
getBranchQualifier in interface javax.transaction.xa.Xidpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic static javax.transaction.xa.Xid getUniqueXid(int threadId)
threadId - can be a real thread id or just some convenient
tracking value.Copyright © 2001 - 2018 HSQL Development Group.