Top Description Inners Fields Constructors Methods
org.h2.jdbcx

public final Class JdbcXAConnection

extends TraceObject
implements XAConnection, XAResource
Class Inheritance
All Implemented Interfaces
javax.transaction.xa.XAResource, javax.sql.XAConnection, javax.sql.PooledConnection
Imports
java.sql.Connection, .ResultSet, .SQLException, .Statement, java.util.ArrayList, javax.sql.ConnectionEvent, .ConnectionEventListener, .StatementEventListener, .XAConnection, javax.transaction.xa.XAException, .XAResource, .Xid, org.h2.api.ErrorCode, org.h2.jdbc.JdbcConnection, org.h2.message.DbException, .TraceObject, org.h2.util.Utils

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 and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
private Xid
private final JdbcDataSourceFactory
private volatile Connection
private final ArrayList<ConnectionEventListener>
private JdbcConnection
private boolean
Inherited from org.h2.message.TraceObject:
ARRAYBLOBCALLABLE_STATEMENTCLOBCONNECTIONDATA_SOURCEDATABASE_META_DATAPARAMETER_META_DATAPREPARED_STATEMENTRESULT_SETRESULT_SET_META_DATASAVEPOINTSQLXMLSTATEMENTtraceXA_DATA_SOURCEXID

Constructor Summary

AccessConstructor and Description
pack-priv
JdbcXAConnection(JdbcDataSourceFactory factory, int id, JdbcConnection physicalConn)

Method Summary

Modifier and TypeMethod and Description
public void
addConnectionEventListener(ConnectionEventListener
the event listener
listener
)

Implements javax.sql.PooledConnection.addConnectionEventListener.

Register a new listener for the connection.

public void
addStatementEventListener(StatementEventListener
the new statement event listener
listener
)

Implements javax.sql.PooledConnection.addStatementEventListener.

[Not supported] Add a statement event listener.

private void
public void
close()

Implements javax.sql.PooledConnection.close.

Close the physical connection.

pack-priv void
closedHandle()

INTERNAL

public void
commit(Xid
the transaction id
xid
,
boolean
use a one-phase protocol if true
onePhase
)

Implements javax.transaction.xa.XAResource.commit.

Commit a transaction.

private static XAException
public void
end(Xid
the transaction id
xid
,
int
TMSUCCESS, TMFAIL, or TMSUSPEND
flags
)

Implements javax.transaction.xa.XAResource.end.

End a transaction.

public void
forget(Xid
the transaction id
xid
)

Implements javax.transaction.xa.XAResource.forget.

Forget a transaction.

public Connection

Returns:

the connection
getConnection
()

Implements javax.sql.PooledConnection.getConnection.

Get a connection that is a handle to the physical connection.

public int

Returns:

0
getTransactionTimeout
()

Implements javax.transaction.xa.XAResource.getTransactionTimeout.

Get the transaction timeout.

public XAResource

Returns:

itself
getXAResource
()

Implements javax.sql.XAConnection.getXAResource.

Get the XAResource object.

public boolean

Returns:

true if this is the same object
isSameRM
(XAResource
the other object
xares
)

Implements javax.transaction.xa.XAResource.isSameRM.

Checks if this is the same XAResource.

public int

Returns:

XA_OK
prepare
(Xid
the transaction id
xid
)

Implements javax.transaction.xa.XAResource.prepare.

Prepare a transaction.

private static String
quoteFlags(int flags)

private static String
public Xid[]

Returns:

zero or more Xid objects
recover
(int
TMSTARTRSCAN, TMENDRSCAN, or TMNOFLAGS. If no other flags are set, TMNOFLAGS must be used.
flag
)

Implements javax.transaction.xa.XAResource.recover.

Get the list of prepared transaction branches.

public void
public void
removeStatementEventListener(StatementEventListener
the statement event listener
listener
)

Implements javax.sql.PooledConnection.removeStatementEventListener.

[Not supported] Remove a statement event listener.

public void
rollback(Xid
the transaction id
xid
)

Implements javax.transaction.xa.XAResource.rollback.

Roll back a transaction.

public boolean

Returns:

false
setTransactionTimeout
(int
ignored
seconds
)

Implements javax.transaction.xa.XAResource.setTransactionTimeout.

Set the transaction timeout.

public void
start(Xid
the transaction id
xid
,
int
TMNOFLAGS, TMJOIN, or TMRESUME
flags
)

Implements javax.transaction.xa.XAResource.start.

Start or continue to work on a transaction.

public String
toString()

Overrides java.lang.Object.toString.

INTERNAL

Inherited from org.h2.message.TraceObject:
debugCodedebugCodeAssigndebugCodeCalldebugCodeCalldebugCodeCallgetNextIdgetTraceIdgetTraceObjectNameisDebugEnabledisInfoEnabledlogAndConvertquotequoteArrayquoteBigDecimalquoteBytesquoteDatequoteIntArrayquoteMapquoteTimequoteTimestampsetTraceunsupported

Field Detail

currentTransactionback to summary
private Xid currentTransaction
factoryback to summary
private final JdbcDataSourceFactory factory
handleConnback to summary
private volatile Connection handleConn
listenersback to summary
private final ArrayList<ConnectionEventListener> listeners
physicalConnback to summary
private JdbcConnection physicalConn
preparedback to summary
private boolean prepared

Constructor Detail

JdbcXAConnectionback to summary
pack-priv JdbcXAConnection(JdbcDataSourceFactory factory, int id, JdbcConnection physicalConn)

Method Detail

addConnectionEventListenerback to summary
public void addConnectionEventListener(ConnectionEventListener listener)

Implements javax.sql.PooledConnection.addConnectionEventListener.

Register a new listener for the connection.

Parameters
listener:ConnectionEventListener

the event listener

Annotations
@Override
addStatementEventListenerback to summary
public void addStatementEventListener(StatementEventListener listener)

Implements javax.sql.PooledConnection.addStatementEventListener.

[Not supported] Add a statement event listener.

Parameters
listener:StatementEventListener

the new statement event listener

Annotations
@Override
checkOpenback to summary
private void checkOpen() throws XAException
closeback to summary
public void close() throws SQLException

Implements javax.sql.PooledConnection.close.

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

Annotations
@Override
Exceptions
SQLException:

Doc from javax.sql.PooledConnection.close.

if a database access error occurs

closedHandleback to summary
pack-priv void closedHandle()

INTERNAL

commitback to summary
public void commit(Xid xid, boolean onePhase) throws XAException

Implements javax.transaction.xa.XAResource.commit.

Commit a transaction.

Parameters
xid:Xid

the transaction id

onePhase:boolean

use a one-phase protocol if true

Annotations
@Override
Exceptions
XAException:

Doc from javax.transaction.xa.XAResource.commit.

An error has occurred. Possible XAExceptions are XA_HEURHAZ, XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.

If the resource manager did not commit the transaction and the paramether onePhase is set to true, the resource manager may throw one of the XA_RB* exceptions. Upon return, the resource manager has rolled back the branch's work and has released all held resources.

convertExceptionback to summary
private static XAException convertException(SQLException e)
endback to summary
public void end(Xid xid, int flags) throws XAException

Implements javax.transaction.xa.XAResource.end.

End a transaction.

Parameters
xid:Xid

the transaction id

flags:int

TMSUCCESS, TMFAIL, or TMSUSPEND

Annotations
@Override
Exceptions
XAException:

Doc from javax.transaction.xa.XAResource.end.

An error has occurred. Possible XAException values are XAER_RMERR, XAER_RMFAILED, XAER_NOTA, XAER_INVAL, XAER_PROTO, or XA_RB*.

forgetback to summary
public void forget(Xid xid)

Implements javax.transaction.xa.XAResource.forget.

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

Parameters
xid:Xid

the transaction id

Annotations
@Override
getConnectionback to summary
public Connection getConnection() throws SQLException

Implements javax.sql.PooledConnection.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.

Returns:Connection

the connection

Annotations
@Override
Exceptions
SQLException:

Doc from javax.sql.PooledConnection.getConnection.

if a database access error occurs

getTransactionTimeoutback to summary
public int getTransactionTimeout()

Implements javax.transaction.xa.XAResource.getTransactionTimeout.

Get the transaction timeout.

Returns:int

0

Annotations
@Override
getXAResourceback to summary
public XAResource getXAResource()

Implements javax.sql.XAConnection.getXAResource.

Get the XAResource object.

Returns:XAResource

itself

Annotations
@Override
isSameRMback to summary
public boolean isSameRM(XAResource xares)

Implements javax.transaction.xa.XAResource.isSameRM.

Checks if this is the same XAResource.

Parameters
xares:XAResource

the other object

Returns:boolean

true if this is the same object

Annotations
@Override
prepareback to summary
public int prepare(Xid xid) throws XAException

Implements javax.transaction.xa.XAResource.prepare.

Prepare a transaction.

Parameters
xid:Xid

the transaction id

Returns:int

XA_OK

Annotations
@Override
Exceptions
XAException:

Doc from javax.transaction.xa.XAResource.prepare.

An error has occurred. Possible exception values are: XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.

quoteFlagsback to summary
private static String quoteFlags(int flags)
quoteXidback to summary
private static String quoteXid(Xid xid)
recoverback to summary
public Xid[] recover(int flag) throws XAException

Implements javax.transaction.xa.XAResource.recover.

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

Parameters
flag:int

TMSTARTRSCAN, TMENDRSCAN, or TMNOFLAGS. If no other flags are set, TMNOFLAGS must be used.

Returns:Xid[]

zero or more Xid objects

Annotations
@Override
Exceptions
XAException:

Doc from javax.transaction.xa.XAResource.recover.

An error has occurred. Possible values are XAER_RMERR, XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.

removeConnectionEventListenerback to summary
public void removeConnectionEventListener(ConnectionEventListener listener)

Implements javax.sql.PooledConnection.removeConnectionEventListener.

Remove the event listener.

Parameters
listener:ConnectionEventListener

the event listener

Annotations
@Override
removeStatementEventListenerback to summary
public void removeStatementEventListener(StatementEventListener listener)

Implements javax.sql.PooledConnection.removeStatementEventListener.

[Not supported] Remove a statement event listener.

Parameters
listener:StatementEventListener

the statement event listener

Annotations
@Override
rollbackback to summary
public void rollback(Xid xid) throws XAException

Implements javax.transaction.xa.XAResource.rollback.

Roll back a transaction.

Parameters
xid:Xid

the transaction id

Annotations
@Override
Exceptions
XAException:

Doc from javax.transaction.xa.XAResource.rollback.

An error has occurred.

setTransactionTimeoutback to summary
public boolean setTransactionTimeout(int seconds)

Implements javax.transaction.xa.XAResource.setTransactionTimeout.

Set the transaction timeout.

Parameters
seconds:int

ignored

Returns:boolean

false

Annotations
@Override
startback to summary
public void start(Xid xid, int flags) throws XAException

Implements javax.transaction.xa.XAResource.start.

Start or continue to work on a transaction.

Parameters
xid:Xid

the transaction id

flags:int

TMNOFLAGS, TMJOIN, or TMRESUME

Annotations
@Override
Exceptions
XAException:

Doc from javax.transaction.xa.XAResource.start.

An error has occurred. Possible exceptions are XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_DUPID, XAER_OUTSIDE, XAER_NOTA, XAER_INVAL, or XAER_PROTO.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

INTERNAL

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override
org.h2.jdbcx back to summary

pack-priv final Class JdbcXAConnection.PooledJdbcConnection

extends JdbcConnection
Class Inheritance

A pooled connection.

Field Summary

Modifier and TypeField and Description
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
public void
close()

Overrides org.h2.jdbc.JdbcConnection.close.

Implements java.sql.Connection.close.

Closes this connection.

public boolean
isClosed()

Overrides org.h2.jdbc.JdbcConnection.isClosed.

Implements java.sql.Connection.isClosed.

Returns true if this connection has been closed.

Inherited from org.h2.jdbc.JdbcConnection:
abortclearWarningscommitcreateArrayOfcreateBlobcreateClobcreateNClobcreateSQLXMLcreateStatementcreateStatementcreateStatementcreateStructcurrentTimestampcurrentTimeZonegetAutoCommitgetCataloggetClientInfogetClientInfogetHoldabilitygetJavaObjectSerializergetMetaDatagetModegetNetworkTimeoutgetSchemagetSessiongetStaticSettingsgetTransactionIsolationgetTypeMapgetWarningsisReadOnlyisValidisWrapperForlocknativeSQLprepareCallprepareCallprepareCallprepareStatementprepareStatementprepareStatementprepareStatementprepareStatementprepareStatementreleaseSavepointrollbackrollbacksetAutoCommitsetCatalogsetClientInfosetClientInfosetHoldabilitysetNetworkTimeoutsetReadOnlysetSavepointsetSavepointsetSchemasetTransactionIsolationsetTypeMaptoStringunlockunwrapzeroBasedEnums

Field Detail

isClosedback to summary
private boolean isClosed

Constructor Detail

PooledJdbcConnectionback to summary
public PooledJdbcConnection(JdbcConnection conn)

Method Detail

checkClosedback to summary
protected void checkClosed()

Overrides org.h2.jdbc.JdbcConnection.checkClosed.

Doc from org.h2.jdbc.JdbcConnection.checkClosed.

INTERNAL. Check if this connection is closed.

Annotations
@Override
closeback to summary
public void close() throws SQLException

Overrides org.h2.jdbc.JdbcConnection.close.

Implements java.sql.Connection.close.

Doc from org.h2.jdbc.JdbcConnection.close.

Closes this connection. All open statements, prepared statements and result sets that where created by this connection become invalid after calling this method. If there is an uncommitted transaction, it will be rolled back.

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Connection.close.

if a database access error occurs

isClosedback to summary
public boolean isClosed() throws SQLException

Overrides org.h2.jdbc.JdbcConnection.isClosed.

Implements java.sql.Connection.isClosed.

Doc from org.h2.jdbc.JdbcConnection.isClosed.

Returns true if this connection has been closed.

Returns:boolean

true if close was called

Annotations
@Override
Exceptions
SQLException:

Doc from java.sql.Connection.isClosed.

if a database access error occurs