/** * Checks if this is the same XAResource. * * @param xares the other object * @return true if this is the same object */ @Override public boolean isSameRM(XAResource xares) { debugCode("isSameRM(xares);"); return xares == this; }
/** * Register a new listener for the connection. * * @param listener the event listener */ @Override public void addConnectionEventListener(ConnectionEventListener listener) { debugCode("addConnectionEventListener(listener);"); listeners.add(listener); }
/** * Remove the event listener. * * @param listener the event listener */ @Override public void removeConnectionEventListener(ConnectionEventListener listener) { debugCode("removeConnectionEventListener(listener);"); listeners.remove(listener); }
/** * INTERNAL */ void closedHandle() { debugCode("closedHandle();"); ConnectionEvent event = new ConnectionEvent(this); // go backward so that a listener can remove itself // (otherwise we need to clone the list) for (int i = listeners.size() - 1; i >= 0; i--) { ConnectionEventListener listener = listeners.get(i); listener.connectionClosed(event); } handleConn = null; }
/** * Forget a transaction. * This method does not have an effect for this database. * * @param xid the transaction id */ @Override public void forget(Xid xid) { if (isDebugEnabled()) { debugCode("forget("+JdbcXid.toString(xid)+");"); } prepared = false; }
/** * End a transaction. * * @param xid the transaction id * @param flags TMSUCCESS, TMFAIL, or TMSUSPEND */ @Override public void end(Xid xid, int flags) throws XAException { if (isDebugEnabled()) { debugCode("end("+JdbcXid.toString(xid)+", "+quoteFlags(flags)+");"); } // TODO transaction end: implement this method if (flags == TMSUSPEND) { return; } if (!currentTransaction.equals(xid)) { throw new XAException(XAException.XAER_OUTSIDE); } prepared = false; }
/** * Prepare a transaction. * * @param xid the transaction id * @return XA_OK */ @Override public int prepare(Xid xid) throws XAException { if (isDebugEnabled()) { debugCode("prepare("+JdbcXid.toString(xid)+");"); } checkOpen(); if (!currentTransaction.equals(xid)) { throw new XAException(XAException.XAER_INVAL); } try (Statement stat = physicalConn.createStatement()) { stat.execute("PREPARE COMMIT " + JdbcXid.toString(xid)); prepared = true; } catch (SQLException e) { throw convertException(e); } return XA_OK; }
/** * Roll back a transaction. * * @param xid the transaction id */ @Override public void rollback(Xid xid) throws XAException { if (isDebugEnabled()) { debugCode("rollback("+JdbcXid.toString(xid)+");"); } try { if (prepared) { try (Statement stat = physicalConn.createStatement()) { stat.execute("ROLLBACK TRANSACTION " + JdbcXid.toString(xid)); } prepared = false; } else { physicalConn.rollback(); } physicalConn.setAutoCommit(true); } catch (SQLException e) { throw convertException(e); } currentTransaction = null; }
/** * Commit a transaction. * * @param xid the transaction id * @param onePhase use a one-phase protocol if true */ @Override public void commit(Xid xid, boolean onePhase) throws XAException { if (isDebugEnabled()) { debugCode("commit("+JdbcXid.toString(xid)+", "+onePhase+");"); } try { if (onePhase) { physicalConn.commit(); } else { try (Statement stat = physicalConn.createStatement()) { stat.execute("COMMIT TRANSACTION " + JdbcXid.toString(xid)); prepared = false; } } physicalConn.setAutoCommit(true); } catch (SQLException e) { throw convertException(e); } currentTransaction = null; }
/** * Start or continue to work on a transaction. * * @param xid the transaction id * @param flags TMNOFLAGS, TMJOIN, or TMRESUME */ @Override public void start(Xid xid, int flags) throws XAException { if (isDebugEnabled()) { debugCode("start("+JdbcXid.toString(xid)+", "+quoteFlags(flags)+");"); } if (flags == TMRESUME) { return; } if (flags == TMJOIN) { if (currentTransaction != null && !currentTransaction.equals(xid)) { throw new XAException(XAException.XAER_RMERR); } } else if (currentTransaction != null) { throw new XAException(XAException.XAER_NOTA); } try { physicalConn.setAutoCommit(false); } catch (SQLException e) { throw convertException(e); } currentTransaction = xid; prepared = false; }
/** * Checks if this is the same XAResource. * * @param xares the other object * @return true if this is the same object */ //## Java 1.4 begin ## public boolean isSameRM(XAResource xares) throws XAException { debugCode("isSameRM(xares);"); return xares == this; } //## Java 1.4 end ##
/** * Checks if this is the same XAResource. * * @param xares the other object * @return true if this is the same object */ @Override public boolean isSameRM(XAResource xares) { debugCode("isSameRM(xares);"); return xares == this; }
/** * Checks if this is the same XAResource. * * @param xares the other object * @return true if this is the same object */ @Override public boolean isSameRM(XAResource xares) { debugCode("isSameRM(xares);"); return xares == this; }
/** * Remove the event listener. * * @param listener the event listener */ //## Java 1.4 begin ## public void removeConnectionEventListener(ConnectionEventListener listener) { debugCode("removeConnectionEventListener(listener);"); listeners.remove(listener); } //## Java 1.4 end ##
/** * Remove the event listener. * * @param listener the event listener */ @Override public void removeConnectionEventListener(ConnectionEventListener listener) { debugCode("removeConnectionEventListener(listener);"); listeners.remove(listener); }
/** * Register a new listener for the connection. * * @param listener the event listener */ @Override public void addConnectionEventListener(ConnectionEventListener listener) { debugCode("addConnectionEventListener(listener);"); listeners.add(listener); }
/** * Register a new listener for the connection. * * @param listener the event listener */ @Override public void addConnectionEventListener(ConnectionEventListener listener) { debugCode("addConnectionEventListener(listener);"); listeners.add(listener); }
/** * Remove the event listener. * * @param listener the event listener */ @Override public void removeConnectionEventListener(ConnectionEventListener listener) { debugCode("removeConnectionEventListener(listener);"); listeners.remove(listener); }
/** * INTERNAL */ //## Java 1.4 begin ## public void closed(JdbcConnection conn) { debugCode("closed(conn);"); for (int i = 0; i < listeners.size(); i++) { ConnectionEventListener listener = (ConnectionEventListener) listeners.get(i); ConnectionEvent event = new ConnectionEvent(this); listener.connectionClosed(event); } } //## Java 1.4 end ##
/** * Forget a transaction. * This method does not have an effect for this database. * * @param xid the transaction id */ //## Java 1.4 begin ## public void forget(Xid xid) throws XAException { if (debug()) { debugCode("forget("+quoteXid(xid)+");"); } } //## Java 1.4 end ##