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.
-
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
Modifier and TypeMethodDescriptionvoid
Register a new listener for the connection.void
[Not supported] Add a statement event listener.void
close()
Close the physical connection.void
Commit a transaction.void
End a transaction.void
Forget a transaction.Get a connection that is a handle to the physical connection.int
Get the transaction timeout.Get the XAResource object.boolean
isSameRM
(XAResource xares) Checks if this is the same XAResource.int
Prepare a transaction.Xid[]
recover
(int flag) Get the list of prepared transaction branches.void
Remove the event listener.void
[Not supported] Remove a statement event listener.void
Roll back a transaction.boolean
setTransactionTimeout
(int seconds) Set the transaction timeout.void
Start or continue to work on a transaction.toString()
INTERNALMethods 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 Details
-
getXAResource
Get the XAResource object.- Specified by:
getXAResource
in interfaceXAConnection
- Returns:
- itself
-
close
Close the physical connection. This method is usually called by the connection pool.- Specified by:
close
in interfacePooledConnection
- Throws:
SQLException
-
getConnection
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 interfacePooledConnection
- Returns:
- the connection
- Throws:
SQLException
-
addConnectionEventListener
Register a new listener for the connection.- Specified by:
addConnectionEventListener
in interfacePooledConnection
- Parameters:
listener
- the event listener
-
removeConnectionEventListener
Remove the event listener.- Specified by:
removeConnectionEventListener
in interfacePooledConnection
- Parameters:
listener
- the event listener
-
getTransactionTimeout
public int getTransactionTimeout()Get the transaction timeout.- Specified by:
getTransactionTimeout
in interfaceXAResource
- Returns:
- 0
-
setTransactionTimeout
public boolean setTransactionTimeout(int seconds) Set the transaction timeout.- Specified by:
setTransactionTimeout
in interfaceXAResource
- Parameters:
seconds
- ignored- Returns:
- false
-
isSameRM
Checks if this is the same XAResource.- Specified by:
isSameRM
in interfaceXAResource
- Parameters:
xares
- the other object- Returns:
- true if this is the same object
-
recover
Get the list of prepared transaction branches. This method is called by the transaction manager during recovery.- Specified by:
recover
in interfaceXAResource
- 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
Prepare a transaction.- Specified by:
prepare
in interfaceXAResource
- Parameters:
xid
- the transaction id- Returns:
- XA_OK
- Throws:
XAException
-
forget
Forget a transaction. This method does not have an effect for this database.- Specified by:
forget
in interfaceXAResource
- Parameters:
xid
- the transaction id
-
rollback
Roll back a transaction.- Specified by:
rollback
in interfaceXAResource
- Parameters:
xid
- the transaction id- Throws:
XAException
-
end
End a transaction.- Specified by:
end
in interfaceXAResource
- Parameters:
xid
- the transaction idflags
- TMSUCCESS, TMFAIL, or TMSUSPEND- Throws:
XAException
-
start
Start or continue to work on a transaction.- Specified by:
start
in interfaceXAResource
- Parameters:
xid
- the transaction idflags
- TMNOFLAGS, TMJOIN, or TMRESUME- Throws:
XAException
-
commit
Commit a transaction.- Specified by:
commit
in interfaceXAResource
- Parameters:
xid
- the transaction idonePhase
- use a one-phase protocol if true- Throws:
XAException
-
addStatementEventListener
[Not supported] Add a statement event listener.- Specified by:
addStatementEventListener
in interfacePooledConnection
- Parameters:
listener
- the new statement event listener
-
removeStatementEventListener
[Not supported] Remove a statement event listener.- Specified by:
removeStatementEventListener
in interfacePooledConnection
- Parameters:
listener
- the statement event listener
-
toString
INTERNAL
-