// 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();
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | |
| pack-priv int | |
| pack-priv boolean | |
| private static byte[] | |
| private static int | |
| pack-priv byte[] | |
| pack-priv byte[] | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object other)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public byte[] | getBranchQualifier()
Implements javax. Obtain the transaction branch identifier part of XID as an array of bytes. |
| public int | getFormatId()
Implements javax. Obtain the format identifier part of the XID. |
| public byte[] | getGlobalTransactionId()
Implements javax. Obtain the global transaction identifier part of XID as an array of bytes. |
| private static byte[] | |
| public static Xid | Returns: a randomly generated JDBCXIDcan be a real thread id or just some convenient
tracking value. threadId)Retrieves a randomly generated JDBCXID. |
| public int | |
| private static int | |
| public String |
| formatID | back to summary |
|---|---|
| pack-priv int formatID | |
| hash | back to summary |
|---|---|
| pack-priv int hash | |
| hashComputed | back to summary |
|---|---|
| pack-priv boolean hashComputed | |
| s_localIp | back to summary |
|---|---|
| private static byte[] s_localIp | |
| s_txnSequenceNumber | back to summary |
|---|---|
| private static int s_txnSequenceNumber | |
| txBranch | back to summary |
|---|---|
| pack-priv byte[] txBranch | |
| txID | back to summary |
|---|---|
| pack-priv byte[] txID | |
| UXID_FORMAT_ID | back to summary |
|---|---|
| private static final int UXID_FORMAT_ID | |
| JDBCXID | back to summary |
|---|---|
| public JDBCXID(int formatID, byte[] txID, byte[] txBranch) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getBranchQualifier | back to summary |
|---|---|
| public byte[] getBranchQualifier() Implements javax. Doc from javax. Obtain the transaction branch identifier part of XID as an array of bytes. | |
| getFormatId | back to summary |
|---|---|
| public int getFormatId() Implements javax. Doc from javax. Obtain the format identifier part of the XID. | |
| getGlobalTransactionId | back to summary |
|---|---|
| public byte[] getGlobalTransactionId() Implements javax. Doc from javax. Obtain the global transaction identifier part of XID as an array of bytes. | |
| getLocalIp | back to summary |
|---|---|
| private static byte[] getLocalIp() | |
| getUniqueXid | back to summary |
|---|---|
| public static Xid getUniqueXid(final int threadId) Retrieves a randomly generated JDBCXID.
The newly generated object is based on the local IP address, the given
Note that java.util.Random is used, not java.security.SecureRandom.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| nextTxnSequenceNumber | back to summary |
|---|---|
| private static int nextTxnSequenceNumber() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |