org.h2.jdbcx

## Class JdbcXAConnection

- java.lang.Object
- - org.h2.message.TraceObject
  - - org.h2.jdbcx.JdbcXAConnection

All Implemented Interfaces:
  javax.sql.PooledConnection, javax.sql.XAConnection, javax.transaction.xa.XAResource

    public class JdbcXAConnection
    extends TraceObject
    implements javax.sql.XAConnection, javax.transaction.xa.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.

### Field Summary

### Fields inherited from class org.h2.message.TraceObject

`ARRAY, BLOB, CALLABLE_STATEMENT, CLOB, CONNECTION, DATA_SOURCE, DATABASE_META_DATA, PARAMETER_META_DATA, PREPARED_STATEMENT, RESULT_SET, RESULT_SET_META_DATA, SAVEPOINT, SQLXML, STATEMENT, trace, XA_DATA_SOURCE, XID`

### Fields inherited from interface javax.transaction.xa.XAResource

`TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY`

### Method Summary

Methods
`void` `addConnectionEventListener(javax.sql.ConnectionEventListener listener)` Register a new listener for the connection.
`void` `addStatementEventListener(javax.sql.StatementEventListener listener)` [Not supported] Add a statement event listener.
`void` `close()` Close the physical connection.
`void` `commit(javax.transaction.xa.Xid xid, boolean onePhase)` Commit a transaction.
`void` `end(javax.transaction.xa.Xid xid, int flags)` End a transaction.
`void` `forget(javax.transaction.xa.Xid xid)` Forget a transaction.
`java.sql.Connection` `getConnection()` Get a connection that is a handle to the physical connection.
`int` `getTransactionTimeout()` Get the transaction timeout.
`javax.transaction.xa.XAResource` `getXAResource()` Get the XAResource object.
`boolean` `isSameRM(javax.transaction.xa.XAResource xares)` Checks if this is the same XAResource.
`int` `prepare(javax.transaction.xa.Xid xid)` Prepare a transaction.
`javax.transaction.xa.Xid[]` `recover(int flag)` Get the list of prepared transaction branches.
`void` `removeConnectionEventListener(javax.sql.ConnectionEventListener listener)` Remove the event listener.
`void` `removeStatementEventListener(javax.sql.StatementEventListener listener)` [Not supported] Remove a statement event listener.
`void` `rollback(javax.transaction.xa.Xid xid)` Roll back a transaction.
`boolean` `setTransactionTimeout(int seconds)` Set the transaction timeout.
`void` `start(javax.transaction.xa.Xid xid, int flags)` Start or continue to work on a transaction.
`java.lang.String` `toString()` INTERNAL

### Methods inherited from class org.h2.message.TraceObject

`debugCode, debugCodeAssign, debugCodeCall, debugCodeCall, debugCodeCall, getNextId, getTraceId, getTraceObjectName, isDebugEnabled, isInfoEnabled, logAndConvert, quote, quoteArray, quoteBigDecimal, quoteBytes, quoteDate, quoteIntArray, quoteMap, quoteTime, quoteTimestamp, setTrace, unsupported`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Method Detail

#### getXAResource

    public javax.transaction.xa.XAResource getXAResource()

Get the XAResource object.

Specified by:
  `getXAResource` in interface `javax.sql.XAConnection`
Returns:
  itself

#### close

    public void close()
               throws java.sql.SQLException

Close the physical connection. This method is usually called by the connection pool.

Specified by:
  `close` in interface `javax.sql.PooledConnection`
Throws:
  `java.sql.SQLException`

#### getConnection

    public java.sql.Connection getConnection()
                                      throws java.sql.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 `javax.sql.PooledConnection`
Returns:
  the connection
Throws:
  `java.sql.SQLException`

#### addConnectionEventListener

    public void addConnectionEventListener(javax.sql.ConnectionEventListener listener)

Register a new listener for the connection.

Specified by:
  `addConnectionEventListener` in interface `javax.sql.PooledConnection`
Parameters:
  `listener` - the event listener

#### removeConnectionEventListener

    public void removeConnectionEventListener(javax.sql.ConnectionEventListener listener)

Remove the event listener.

Specified by:
  `removeConnectionEventListener` in interface `javax.sql.PooledConnection`
Parameters:
  `listener` - the event listener

#### getTransactionTimeout

    public int getTransactionTimeout()

Get the transaction timeout.

Specified by:
  `getTransactionTimeout` in interface `javax.transaction.xa.XAResource`
Returns:
  0

#### setTransactionTimeout

    public boolean setTransactionTimeout(int seconds)

Set the transaction timeout.

Specified by:
  `setTransactionTimeout` in interface `javax.transaction.xa.XAResource`
Parameters:
  `seconds` - ignored
Returns:
  false

#### isSameRM

    public boolean isSameRM(javax.transaction.xa.XAResource xares)

Checks if this is the same XAResource.

Specified by:
  `isSameRM` in interface `javax.transaction.xa.XAResource`
Parameters:
  `xares` - the other object
Returns:
  true if this is the same object

#### recover

    public javax.transaction.xa.Xid[] recover(int flag)
                                       throws javax.transaction.xa.XAException

Get the list of prepared transaction branches. This method is called by the transaction manager during recovery.

Specified by:
  `recover` in interface `javax.transaction.xa.XAResource`
Parameters:
  `flag` - TMSTARTRSCAN, TMENDRSCAN, or TMNOFLAGS. If no other flags are set, TMNOFLAGS must be used.
Returns:
  zero or more Xid objects
Throws:
  `javax.transaction.xa.XAException`

#### prepare

    public int prepare(javax.transaction.xa.Xid xid)
                throws javax.transaction.xa.XAException

Prepare a transaction.

Specified by:
  `prepare` in interface `javax.transaction.xa.XAResource`
Parameters:
  `xid` - the transaction id
Returns:
  XA_OK
Throws:
  `javax.transaction.xa.XAException`

#### forget

    public void forget(javax.transaction.xa.Xid xid)

Forget a transaction. This method does not have an effect for this database.

Specified by:
  `forget` in interface `javax.transaction.xa.XAResource`
Parameters:
  `xid` - the transaction id

#### rollback

    public void rollback(javax.transaction.xa.Xid xid)
                  throws javax.transaction.xa.XAException

Roll back a transaction.

Specified by:
  `rollback` in interface `javax.transaction.xa.XAResource`
Parameters:
  `xid` - the transaction id
Throws:
  `javax.transaction.xa.XAException`

#### end

    public void end(javax.transaction.xa.Xid xid,
           int flags)
             throws javax.transaction.xa.XAException

End a transaction.

Specified by:
  `end` in interface `javax.transaction.xa.XAResource`
Parameters:
  `xid` - the transaction id
  `flags` - TMSUCCESS, TMFAIL, or TMSUSPEND
Throws:
  `javax.transaction.xa.XAException`

#### start

    public void start(javax.transaction.xa.Xid xid,
             int flags)
               throws javax.transaction.xa.XAException

Start or continue to work on a transaction.

Specified by:
  `start` in interface `javax.transaction.xa.XAResource`
Parameters:
  `xid` - the transaction id
  `flags` - TMNOFLAGS, TMJOIN, or TMRESUME
Throws:
  `javax.transaction.xa.XAException`

#### commit

    public void commit(javax.transaction.xa.Xid xid,
              boolean onePhase)
                throws javax.transaction.xa.XAException

Commit a transaction.

Specified by:
  `commit` in interface `javax.transaction.xa.XAResource`
Parameters:
  `xid` - the transaction id
  `onePhase` - use a one-phase protocol if true
Throws:
  `javax.transaction.xa.XAException`

#### addStatementEventListener

    public void addStatementEventListener(javax.sql.StatementEventListener listener)

[Not supported] Add a statement event listener.

Specified by:
  `addStatementEventListener` in interface `javax.sql.PooledConnection`
Parameters:
  `listener` - the new statement event listener

#### removeStatementEventListener

    public void removeStatementEventListener(javax.sql.StatementEventListener listener)

[Not supported] Remove a statement event listener.

Specified by:
  `removeStatementEventListener` in interface `javax.sql.PooledConnection`
Parameters:
  `listener` - the statement event listener

#### toString

    public java.lang.String toString()

INTERNAL

Overrides:
  `toString` in class `java.lang.Object`