Class JdbcXAConnection
java.lang.Object
org.h2.message.TraceObject
org.h2.jdbcx.JdbcXAConnection
- All Implemented Interfaces:
PooledConnection, 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) final classA pooled connection. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Xidprivate final JdbcDataSourceFactoryprivate Connectionprivate final ArrayList<ConnectionEventListener> private JdbcConnectionprivate booleanFields inherited from class 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, XIDFields inherited from interface XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY -
Constructor Summary
ConstructorsConstructorDescriptionJdbcXAConnection(JdbcDataSourceFactory factory, int id, JdbcConnection physicalConn) -
Method Summary
Modifier and TypeMethodDescriptionvoidRegister a new listener for the connection.void[Not supported] Add a statement event listener.private voidvoidclose()Close the physical connection.(package private) voidINTERNALvoidCommit a transaction.private static XAExceptionvoidEnd a transaction.voidForget a transaction.Get a connection that is a handle to the physical connection.intGet the transaction timeout.Get the XAResource object.booleanisSameRM(XAResource xares) Checks if this is the same XAResource.intPrepare a transaction.private static StringquoteFlags(int flags) private static StringXid[]recover(int flag) Get the list of prepared transaction branches.voidRemove the event listener.void[Not supported] Remove a statement event listener.voidRoll back a transaction.booleansetTransactionTimeout(int seconds) Set the transaction timeout.voidStart or continue to work on a transaction.toString()INTERNALMethods inherited from class TraceObject
debugCode, debugCodeAssign, debugCodeCall, debugCodeCall, debugCodeCall, getNextId, getTraceId, getTraceObjectName, isDebugEnabled, isInfoEnabled, logAndConvert, quote, quoteArray, quoteBigDecimal, quoteBytes, quoteDate, quoteIntArray, quoteMap, quoteTime, quoteTimestamp, setTrace, unsupported
-
Field Details
-
factory
-
physicalConn
-
handleConn
-
listeners
-
currentTransaction
-
prepared
private boolean prepared
-
-
Constructor Details
-
JdbcXAConnection
JdbcXAConnection(JdbcDataSourceFactory factory, int id, JdbcConnection physicalConn)
-
-
Method Details
-
getXAResource
Get the XAResource object.- Specified by:
getXAResourcein interfaceXAConnection- Returns:
- itself
-
close
Close the physical connection. This method is usually called by the connection pool.- Specified by:
closein 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:
getConnectionin interfacePooledConnection- Returns:
- the connection
- Throws:
SQLException
-
addConnectionEventListener
Register a new listener for the connection.- Specified by:
addConnectionEventListenerin interfacePooledConnection- Parameters:
listener- the event listener
-
removeConnectionEventListener
Remove the event listener.- Specified by:
removeConnectionEventListenerin interfacePooledConnection- Parameters:
listener- the event listener
-
closedHandle
void closedHandle()INTERNAL -
getTransactionTimeout
public int getTransactionTimeout()Get the transaction timeout.- Specified by:
getTransactionTimeoutin interfaceXAResource- Returns:
- 0
-
setTransactionTimeout
public boolean setTransactionTimeout(int seconds) Set the transaction timeout.- Specified by:
setTransactionTimeoutin interfaceXAResource- Parameters:
seconds- ignored- Returns:
- false
-
isSameRM
Checks if this is the same XAResource.- Specified by:
isSameRMin 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:
recoverin 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:
preparein 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:
forgetin interfaceXAResource- Parameters:
xid- the transaction id
-
rollback
Roll back a transaction.- Specified by:
rollbackin interfaceXAResource- Parameters:
xid- the transaction id- Throws:
XAException
-
end
End a transaction.- Specified by:
endin interfaceXAResource- Parameters:
xid- the transaction idflags- TMSUCCESS, TMFAIL, or TMSUSPEND- Throws:
XAException
-
start
Start or continue to work on a transaction.- Specified by:
startin interfaceXAResource- Parameters:
xid- the transaction idflags- TMNOFLAGS, TMJOIN, or TMRESUME- Throws:
XAException
-
commit
Commit a transaction.- Specified by:
commitin 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:
addStatementEventListenerin interfacePooledConnection- Parameters:
listener- the new statement event listener
-
removeStatementEventListener
[Not supported] Remove a statement event listener.- Specified by:
removeStatementEventListenerin interfacePooledConnection- Parameters:
listener- the statement event listener
-
toString
-
convertException
-
quoteXid
-
quoteFlags
-
checkOpen
- Throws:
XAException
-