Package org.h2.jdbcx

Class JdbcXAConnection

java.lang.Object
org.h2.message.TraceObject
org.h2.jdbcx.JdbcXAConnection
All Implemented Interfaces:
PooledConnection, XAConnection, XAResource

public final class JdbcXAConnection extends org.h2.message.TraceObject implements XAConnection, XAResource
This class provides support for distributed transactions. An application developer usually does not use this interface. It is used by the transaction manager internally.
  • Method Details

    • getXAResource

      public XAResource getXAResource()
      Get the XAResource object.
      Specified by:
      getXAResource in interface XAConnection
      Returns:
      itself
    • close

      public void close() throws SQLException
      Close the physical connection. This method is usually called by the connection pool.
      Specified by:
      close in interface PooledConnection
      Throws:
      SQLException
    • getConnection

      public Connection getConnection() throws SQLException
      Get a connection that is a handle to the physical connection. This method is usually called by the connection pool. This method closes the last connection handle if one exists.
      Specified by:
      getConnection in interface PooledConnection
      Returns:
      the connection
      Throws:
      SQLException
    • addConnectionEventListener

      public void addConnectionEventListener(ConnectionEventListener listener)
      Register a new listener for the connection.
      Specified by:
      addConnectionEventListener in interface PooledConnection
      Parameters:
      listener - the event listener
    • removeConnectionEventListener

      public void removeConnectionEventListener(ConnectionEventListener listener)
      Remove the event listener.
      Specified by:
      removeConnectionEventListener in interface PooledConnection
      Parameters:
      listener - the event listener
    • getTransactionTimeout

      public int getTransactionTimeout()
      Get the transaction timeout.
      Specified by:
      getTransactionTimeout in interface XAResource
      Returns:
      0
    • setTransactionTimeout

      public boolean setTransactionTimeout(int seconds)
      Set the transaction timeout.
      Specified by:
      setTransactionTimeout in interface XAResource
      Parameters:
      seconds - ignored
      Returns:
      false
    • isSameRM

      public boolean isSameRM(XAResource xares)
      Checks if this is the same XAResource.
      Specified by:
      isSameRM in interface XAResource
      Parameters:
      xares - the other object
      Returns:
      true if this is the same object
    • recover

      public Xid[] recover(int flag) throws XAException
      Get the list of prepared transaction branches. This method is called by the transaction manager during recovery.
      Specified by:
      recover in interface XAResource
      Parameters:
      flag - TMSTARTRSCAN, TMENDRSCAN, or TMNOFLAGS. If no other flags are set, TMNOFLAGS must be used.
      Returns:
      zero or more Xid objects
      Throws:
      XAException
    • prepare

      public int prepare(Xid xid) throws XAException
      Prepare a transaction.
      Specified by:
      prepare in interface XAResource
      Parameters:
      xid - the transaction id
      Returns:
      XA_OK
      Throws:
      XAException
    • forget

      public void forget(Xid xid)
      Forget a transaction. This method does not have an effect for this database.
      Specified by:
      forget in interface XAResource
      Parameters:
      xid - the transaction id
    • rollback

      public void rollback(Xid xid) throws XAException
      Roll back a transaction.
      Specified by:
      rollback in interface XAResource
      Parameters:
      xid - the transaction id
      Throws:
      XAException
    • end

      public void end(Xid xid, int flags) throws XAException
      End a transaction.
      Specified by:
      end in interface XAResource
      Parameters:
      xid - the transaction id
      flags - TMSUCCESS, TMFAIL, or TMSUSPEND
      Throws:
      XAException
    • start

      public void start(Xid xid, int flags) throws XAException
      Start or continue to work on a transaction.
      Specified by:
      start in interface XAResource
      Parameters:
      xid - the transaction id
      flags - TMNOFLAGS, TMJOIN, or TMRESUME
      Throws:
      XAException
    • commit

      public void commit(Xid xid, boolean onePhase) throws XAException
      Commit a transaction.
      Specified by:
      commit in interface XAResource
      Parameters:
      xid - the transaction id
      onePhase - use a one-phase protocol if true
      Throws:
      XAException
    • addStatementEventListener

      public void addStatementEventListener(StatementEventListener listener)
      [Not supported] Add a statement event listener.
      Specified by:
      addStatementEventListener in interface PooledConnection
      Parameters:
      listener - the new statement event listener
    • removeStatementEventListener

      public void removeStatementEventListener(StatementEventListener listener)
      [Not supported] Remove a statement event listener.
      Specified by:
      removeStatementEventListener in interface PooledConnection
      Parameters:
      listener - the statement event listener
    • toString

      public String toString()
      INTERNAL
      Overrides:
      toString in class Object