protected int doEnd(Xid xid, int flag) throws XAException {
   int returnVal = -1;
   synchronized (physicalConn) {
     synchronized (this) {
       try {
         try {
           T4CTTIOtxse otxse = physicalConn.otxse;
           byte xidxid[] = null;
           byte gtrid[] = xid.getGlobalTransactionId();
           byte bqual[] = xid.getBranchQualifier();
           int gtrid_l = 0;
           int bqual_l = 0;
           if (gtrid != null && bqual != null) {
             gtrid_l = Math.min(gtrid.length, 64);
             bqual_l = Math.min(bqual.length, 64);
             xidxid = new byte[128];
             System.arraycopy(gtrid, 0, xidxid, 0, gtrid_l);
             System.arraycopy(bqual, 0, xidxid, gtrid_l, bqual_l);
           }
           byte txctx[] = context;
           int t4cflag = 0;
           if (((flag & 2) == 2 || (flag & 0x100000) != 0x100000)
               && (flag & 0x2000000) == 0x2000000) {
             t4cflag = 0x100000;
           }
           physicalConn.sendPiggyBackedMessages();
           otxse.marshal(2, txctx, xidxid, xid.getFormatId(), gtrid_l, bqual_l, timeout, t4cflag);
           byte ctx[] = otxse.receive(applicationValueArr);
           if (ctx != null) {
             context = ctx;
           }
           returnVal = 0;
         } catch (IOException ioe) {
           DatabaseError.throwSqlException(ioe);
         }
       } catch (SQLException s) {
         returnVal = s.getErrorCode();
         if (returnVal == 0) {
           throw new XAException(-6);
         }
       }
     }
   }
   return returnVal;
 }
  protected int doStart(Xid xid, int flag) throws XAException {
    int returnVal = -1;

    synchronized (this.physicalConn) {
      synchronized (this) {
        if (this.isTransLoose) {
          flag |= 65536;
        }

        int swtch = flag & 0x8200000;

        if ((swtch == 134217728) && (OracleXid.isLocalTransaction(xid))) {
          return 0;
        }

        this.applicationValueArr[0] = 0;
        try {
          try {
            T4CTTIOtxse otxse = this.physicalConn.otxse;
            byte[] xidxid = null;
            byte[] gtrid = xid.getGlobalTransactionId();
            byte[] bqual = xid.getBranchQualifier();

            int gtrid_l = 0;
            int bqual_l = 0;

            if ((gtrid != null) && (bqual != null)) {
              gtrid_l = Math.min(gtrid.length, 64);
              bqual_l = Math.min(bqual.length, 64);
              xidxid = new byte['\u0080'];

              System.arraycopy(gtrid, 0, xidxid, 0, gtrid_l);
              System.arraycopy(bqual, 0, xidxid, gtrid_l, bqual_l);
            }

            int t4cflag = 0;

            if (((flag & 0x200000) != 0) || ((flag & 0x8000000) != 0)) t4cflag |= 4;
            else {
              t4cflag |= 1;
            }
            if ((flag & 0x100) != 0) {
              t4cflag |= 256;
            }
            if ((flag & 0x200) != 0) {
              t4cflag |= 512;
            }
            if ((flag & 0x400) != 0) {
              t4cflag |= 1024;
            }
            if ((flag & 0x10000) != 0) {
              t4cflag |= 65536;
            }
            this.physicalConn.sendPiggyBackedMessages();
            otxse.marshal(
                1, null, xidxid, xid.getFormatId(), gtrid_l, bqual_l, this.timeout, t4cflag);

            byte[] ctx = otxse.receive(this.applicationValueArr);

            if (ctx != null) {
              this.context = ctx;
            }
            returnVal = 0;
          } catch (IOException ioe) {
            DatabaseError.throwSqlException(ioe);
          }

        } catch (SQLException s) {
          returnVal = s.getErrorCode();

          if (returnVal == 0) {
            throw new XAException(-6);
          }
        }
      }
    }

    return returnVal;
  }