Пример #1
0
  public void end(Xid xid, int flags) throws XAException {

    validateXid(xid);

    if (state != XA_STATE_STARTED) {
      throw new XAException("Invalid XAResource state");
    }

    try {
      connection.setAutoCommit(originalAutoCommitMode); // real/phys.
    } catch (SQLException se) {
      throw new XAException(se.getMessage());
    }

    state = XA_STATE_ENDED;
  }
Пример #2
0
  public void start(Xid xid, int flags) throws XAException {

    // Comment out following debug statement before public release:
    System.err.println("STARTING NEW Xid: " + xid);

    if (state != XA_STATE_INITIAL && state != XA_STATE_DISPOSED) {
      throw new XAException("Invalid XAResource state");
    }

    if (xaDataSource == null) {
      throw new XAException("JDBCXAResource has not been associated with a XADataSource");
    }

    if (xid == null) {

      // This block asserts that all JDBCXAResources with state
      // >= XA_STATE_STARTED have a non-null xid.
      throw new XAException("Null Xid");
    }

    try {
      originalAutoCommitMode = connection.getAutoCommit(); // real/phys.

      connection.setAutoCommit(false); // real/phys.
    } catch (SQLException se) {
      throw new XAException(se.getMessage());
    }

    this.xid = xid;
    state = XA_STATE_STARTED;

    xaDataSource.addResource(this.xid, this);

    // N.b.  The DataSource does not have this XAResource in its list
    // until right here.  We can't tell DataSource before our start()
    // method, because we don't know our Xid before now.
  }