int doTransaction(Xid xid, int mode, int command) throws XAException {
   int returnVal = -1;
   try {
     try {
       T4CTTIOtxen otxen = physicalConn.otxen;
       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;
       physicalConn.sendPiggyBackedMessages();
       otxen.marshal(mode, txctx, xidxid, xid.getFormatId(), gtrid_l, bqual_l, timeout, command);
       returnVal = otxen.receive(errorNumber);
     } catch (IOException ioe) {
       DatabaseError.throwSqlException(ioe);
     }
   } catch (SQLException s) {
     errorNumber[0] = s.getErrorCode();
   }
   if (errorNumber[0] == 0) {
     throw new XAException(-6);
   }
   if (returnVal == -1) {
     returnVal = errorNumber[0];
   }
   return returnVal;
 }
 protected int doCommit(Xid xid, int cPhase) throws XAException {
   int returnVal = -1;
   synchronized (physicalConn) {
     synchronized (this) {
       int command = cPhase != 1 ? 2 : 4;
       returnVal = doTransaction(xid, 1, command);
       if (cPhase == 1 && (returnVal == 2 || returnVal == 4)) {
         returnVal = 0;
       } else if (cPhase != 1 && returnVal == 5) {
         returnVal = 0;
       } else if (returnVal == 8) {
         throw new XAException(106);
       }
       if (returnVal == 24756) {
         returnVal = kputxrec(xid, 1, timeout + 120);
       } else if (returnVal == 24780) {
         OracleXADataSource oxds = null;
         XAConnection pc = null;
         try {
           oxds = new OracleXADataSource();
           oxds.setURL(physicalConn.url);
           oxds.setUser(physicalConn.user);
           physicalConn.getPasswordInternal(this);
           oxds.setPassword(password);
           pc = oxds.getXAConnection();
           XAResource oxar = pc.getXAResource();
           oxar.commit(xid, cPhase == 1);
           returnVal = 0;
         } catch (SQLException e) {
           throw new XAException(-6);
         } finally {
           try {
             if (pc != null) {
               pc.close();
             }
             if (oxds != null) {
               oxds.close();
             }
           } catch (Exception ee) {
           }
         }
       }
     }
   }
   return returnVal;
 }
 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 doRollback(Xid xid) throws XAException {
   int returnVal = -1;
   synchronized (physicalConn) {
     synchronized (this) {
       returnVal = doTransaction(xid, 2, 3);
       if (returnVal == 8) {
         throw new XAException(106);
       }
       if (returnVal == 3 || returnVal == 25402) {
         returnVal = 0;
       }
       if (returnVal == 24756) {
         returnVal = kputxrec(xid, 2, timeout + 120);
       } else if (returnVal == 24780) {
         OracleXADataSource oxds = null;
         XAConnection pc = null;
         try {
           oxds = new OracleXADataSource();
           oxds.setURL(physicalConn.url);
           oxds.setUser(physicalConn.user);
           physicalConn.getPasswordInternal(this);
           oxds.setPassword(password);
           pc = oxds.getXAConnection();
           XAResource oxar = pc.getXAResource();
           oxar.rollback(xid);
           returnVal = 0;
         } catch (SQLException e) {
           throw new XAException(-6);
         } finally {
           try {
             if (pc != null) {
               pc.close();
             }
             if (oxds != null) {
               oxds.close();
             }
           } catch (Exception ee) {
           }
         }
       }
     }
   }
   return returnVal;
 }