public class JDBCXID extends Object implements 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();
MAXBQUALSIZE, MAXGTRIDSIZE
Constructor and Description |
---|
JDBCXID(int formatID,
byte[] txID,
byte[] txBranch) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
byte[] |
getBranchQualifier() |
int |
getFormatId() |
byte[] |
getGlobalTransactionId() |
static Xid |
getUniqueXid(int threadId)
Retrieves a randomly generated JDBCXID.
|
int |
hashCode() |
String |
toString() |
public int getFormatId()
getFormatId
in interface Xid
public byte[] getGlobalTransactionId()
getGlobalTransactionId
in interface Xid
public byte[] getBranchQualifier()
getBranchQualifier
in interface Xid
public static Xid getUniqueXid(int threadId)
threadId
- can be a real thread id or just some convenient
tracking value.Copyright © 2001 - 2017 HSQL Development Group.