org.hsqldb.jdbc.pool

## Class JDBCXID

- java.lang.Object
- - org.hsqldb.jdbc.pool.JDBCXID

- All Implemented Interfaces:
    javax.transaction.xa.Xid

      public class JDBCXID
      extends java.lang.Object
      implements javax.transaction.xa.Xid

  Implementation of Xid for tests.

       // 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();

  Author:
    Fred Toussi (fredt@users dot sourceforge.net), Campbell Burnet (campbell-burnet@users dot sourceforge.net)

- - ### Field Summary

    - ### Fields inherited from interface javax.transaction.xa.Xid

      `MAXBQUALSIZE, MAXGTRIDSIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JDBCXID(int formatID, byte[] txID, byte[] txBranch)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    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()`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### JDBCXID

          public JDBCXID(int formatID,
                         byte[] txID,
                         byte[] txBranch)

  - ### Method Detail

    - #### getFormatId

          public int getFormatId()

      Specified by:
        `getFormatId` in interface `javax.transaction.xa.Xid`

    - #### getGlobalTransactionId

          public byte[] getGlobalTransactionId()

      Specified by:
        `getGlobalTransactionId` in interface `javax.transaction.xa.Xid`

    - #### getBranchQualifier

          public byte[] getBranchQualifier()

      Specified by:
        `getBranchQualifier` in interface `javax.transaction.xa.Xid`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object other)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getUniqueXid

          public static javax.transaction.xa.Xid getUniqueXid(int threadId)

      Retrieves a randomly generated JDBCXID. The newly generated object is based on the local IP address, the given `threadId` and a randomly generated number using the current time in milliseconds as the random seed. Note that java.util.Random is used, not java.security.SecureRandom.
      Parameters:
        `threadId` - can be a real thread id or just some convenient tracking value.
      Returns:
        a randomly generated JDBCXID

Copyright © 2001 - 2018 HSQL Development Group.