Package 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 final class JdbcXAConnection extends org.h2.message.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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
-
-
-
Method Detail
-
getXAResource
public javax.transaction.xa.XAResource getXAResource()
Get the XAResource object.- Specified by:
getXAResource
in interfacejavax.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 interfacejavax.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 interfacejavax.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 interfacejavax.sql.PooledConnection
- Parameters:
listener
- the event listener
-
removeConnectionEventListener
public void removeConnectionEventListener(javax.sql.ConnectionEventListener listener)
Remove the event listener.- Specified by:
removeConnectionEventListener
in interfacejavax.sql.PooledConnection
- Parameters:
listener
- the event listener
-
getTransactionTimeout
public int getTransactionTimeout()
Get the transaction timeout.- Specified by:
getTransactionTimeout
in interfacejavax.transaction.xa.XAResource
- Returns:
- 0
-
setTransactionTimeout
public boolean setTransactionTimeout(int seconds)
Set the transaction timeout.- Specified by:
setTransactionTimeout
in interfacejavax.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 interfacejavax.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 interfacejavax.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 interfacejavax.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 interfacejavax.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 interfacejavax.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 interfacejavax.transaction.xa.XAResource
- Parameters:
xid
- the transaction idflags
- 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 interfacejavax.transaction.xa.XAResource
- Parameters:
xid
- the transaction idflags
- 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 interfacejavax.transaction.xa.XAResource
- Parameters:
xid
- the transaction idonePhase
- 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 interfacejavax.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 interfacejavax.sql.PooledConnection
- Parameters:
listener
- the statement event listener
-
toString
public java.lang.String toString()
INTERNAL- Overrides:
toString
in classjava.lang.Object
-
-