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.Xid
public byte[] getGlobalTransactionId()
getGlobalTransactionId
in interface javax.transaction.xa.Xid
public byte[] getBranchQualifier()
getBranchQualifier
in interface javax.transaction.xa.Xid
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static javax.transaction.xa.Xid getUniqueXid(int threadId)
threadId
- can be a real thread id or just some convenient
tracking value.Copyright �� 2001 - 2017 HSQL Development Group.