Top Fields Constructors Methods
com.mysql.cj.jdbc

public Class SuspendableXAConnection

extends MysqlPooledConnection
implements XAConnection, XAResource
Class Inheritance
All Implemented Interfaces
javax.transaction.xa.XAResource, javax.sql.XAConnection, javax.sql.PooledConnection
Imports
java.sql.SQLException, java.util.HashMap, .Map, java.util.concurrent.locks.Lock, .ReentrantLock, javax.sql.XAConnection, javax.transaction.xa.XAException, .XAResource, .Xid, com.mysql.cj.conf.PropertyKey

Field Summary

Modifier and TypeField and Description
private XAConnection
private XAResource
private Xid
private static final Lock
private final Lock
private JdbcConnection
private static final Map<Xid, XAConnection>
Inherited from com.mysql.cj.jdbc.MysqlPooledConnection:
CONNECTION_CLOSED_EVENTCONNECTION_ERROR_EVENT

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides com.mysql.cj.jdbc.MysqlPooledConnection.close.

Implements javax.sql.PooledConnection.close.

Closes the physical connection that this PooledConnection object represents.

public void
commit(Xid
A global transaction identifier
xid
,
boolean
If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of xid.
arg1
)

Implements javax.transaction.xa.XAResource.commit.

Commits the global transaction specified by xid.

public void
end(Xid
A global transaction identifier that is the same as the identifier used previously in the start method.
xid
,
int
One of TMSUCCESS, TMFAIL, or TMSUSPEND.
arg1
)

Implements javax.transaction.xa.XAResource.end.

Ends the work performed on behalf of a transaction branch.

private static XAConnection
findConnectionForXid(JdbcConnection connectionToWrap, Xid xid)

public void
forget(Xid
A global transaction identifier.
xid
)

Implements javax.transaction.xa.XAResource.forget.

Tells the resource manager to forget about a heuristically completed transaction branch.

public Connection
getConnection()

Overrides com.mysql.cj.jdbc.MysqlPooledConnection.getConnection.

Implements javax.sql.PooledConnection.getConnection.

Creates and returns a Connection object that is a handle for the physical connection that this PooledConnection object represents.

protected static SuspendableXAConnection
public int
getTransactionTimeout()

Implements javax.transaction.xa.XAResource.getTransactionTimeout.

Obtains the current transaction timeout value set for this XAResource instance.

public XAResource
getXAResource()

Implements javax.sql.XAConnection.getXAResource.

Retrieves an XAResource object that the transaction manager will use to manage this XAConnection object's participation in a distributed transaction.

public boolean
isSameRM(XAResource
An XAResource object whose resource manager instance is to be compared with the resource manager instance of the target object.
xaRes
)

Implements javax.transaction.xa.XAResource.isSameRM.

This method is called to determine if the resource manager instance represented by the target object is the same as the resource manager instance represented by the parameter xares.

public int
prepare(Xid
A global transaction identifier.
xid
)

Implements javax.transaction.xa.XAResource.prepare.

Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.

public Xid[]
recover(int
One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other flags are set in the parameter.
flag
)

Implements javax.transaction.xa.XAResource.recover.

Obtains a list of prepared transaction branches from a resource manager.

private static void
public void
rollback(Xid
A global transaction identifier.
xid
)

Implements javax.transaction.xa.XAResource.rollback.

Informs the resource manager to roll back work done on behalf of a transaction branch.

public boolean
setTransactionTimeout(int
The transaction timeout value in seconds.
arg0
)

Implements javax.transaction.xa.XAResource.setTransactionTimeout.

Sets the current transaction timeout value for this XAResource instance.

public void
start(Xid
A global transaction identifier to be associated with the resource.
xid
,
int
One of TMNOFLAGS, TMJOIN, or TMRESUME.
arg1
)

Implements javax.transaction.xa.XAResource.start.

Starts work on behalf of a transaction branch specified in xid.

private void
Inherited from com.mysql.cj.jdbc.MysqlPooledConnection:
addConnectionEventListeneraddStatementEventListenercallConnectionEventListenersfireStatementEventgetConnectiongetExceptionInterceptorgetLockremoveConnectionEventListenerremoveStatementEventListener

Field Detail

currentXAConnectionback to summary
private XAConnection currentXAConnection
currentXAResourceback to summary
private XAResource currentXAResource
currentXidback to summary
private Xid currentXid
LOCKback to summary
private static final Lock LOCK
lockback to summary
private final Lock lock

Hides com.mysql.cj.jdbc.MysqlPooledConnection.lock.

underlyingConnectionback to summary
private JdbcConnection underlyingConnection
XIDS_TO_PHYSICAL_CONNECTIONSback to summary
private static final Map<Xid, XAConnection> XIDS_TO_PHYSICAL_CONNECTIONS

Constructor Detail

SuspendableXAConnectionback to summary
public SuspendableXAConnection(JdbcConnection connection)

Method Detail

closeback to summary
public void close() throws SQLException

Overrides com.mysql.cj.jdbc.MysqlPooledConnection.close.

Implements javax.sql.PooledConnection.close.

Doc from javax.sql.PooledConnection.close.

Closes the physical connection that this PooledConnection object represents. An application never calls this method directly; it is called by the connection pool module, or manager.

See the interface description for more information.

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs
commitback to summary
public void commit(Xid xid, boolean arg1) throws XAException

Implements javax.transaction.xa.XAResource.commit.

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

Commits the global transaction specified by xid.

Parameters
xid:Xid

A global transaction identifier

arg1:boolean

If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of xid.

Annotations
@Override
Exceptions
XAException:
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.

endback to summary
public void end(Xid xid, int arg1) throws XAException

Implements javax.transaction.xa.XAResource.end.

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

Ends the work performed on behalf of a transaction branch. The resource manager disassociates the XA resource from the transaction branch specified and lets the transaction complete.

If TMSUSPEND is specified in the flags, the transaction branch is temporarily suspended in an incomplete state. The transaction context is in a suspended state and must be resumed via the start method with TMRESUME specified.

If TMFAIL is specified, the portion of work has failed. The resource manager may mark the transaction as rollback-only

If TMSUCCESS is specified, the portion of work has completed successfully.

Parameters
xid:Xid

A global transaction identifier that is the same as the identifier used previously in the start method.

arg1:int

One of TMSUCCESS, TMFAIL, or TMSUSPEND.

Annotations
@Override
Exceptions
XAException:
An error has occurred. Possible XAException values are XAER_RMERR, XAER_RMFAILED, XAER_NOTA, XAER_INVAL, XAER_PROTO, or XA_RB*.
findConnectionForXidback to summary
private static XAConnection findConnectionForXid(JdbcConnection connectionToWrap, Xid xid) throws SQLException
forgetback to summary
public void forget(Xid xid) throws XAException

Implements javax.transaction.xa.XAResource.forget.

Doc from javax.transaction.xa.XAResource.forget.

Tells the resource manager to forget about a heuristically completed transaction branch.

Parameters
xid:Xid

A global transaction identifier.

Annotations
@Override
Exceptions
XAException:
An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
getConnectionback to summary
public Connection getConnection() throws SQLException

Overrides com.mysql.cj.jdbc.MysqlPooledConnection.getConnection.

Implements javax.sql.PooledConnection.getConnection.

Doc from javax.sql.PooledConnection.getConnection.

Creates and returns a Connection object that is a handle for the physical connection that this PooledConnection object represents. The connection pool manager calls this method when an application has called the method DataSource.getConnection and there are no PooledConnection objects available. See the interface description for more information.

Returns:Connection

a Connection object that is a handle to this PooledConnection object

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs
getInstanceback to summary
protected static SuspendableXAConnection getInstance(JdbcConnection mysqlConnection) throws SQLException

Hides com.mysql.cj.jdbc.MysqlPooledConnection.getInstance.

getTransactionTimeoutback to summary
public int getTransactionTimeout() throws XAException

Implements javax.transaction.xa.XAResource.getTransactionTimeout.

Doc from javax.transaction.xa.XAResource.getTransactionTimeout.

Obtains the current transaction timeout value set for this XAResource instance. If XAResource.setTransactionTimeout was not used prior to invoking this method, the return value is the default timeout set for the resource manager; otherwise, the value used in the previous setTransactionTimeout call is returned.

Returns:int

the transaction timeout value in seconds.

Annotations
@Override
Exceptions
XAException:
An error has occurred. Possible exception values are XAER_RMERR and XAER_RMFAIL.
getXAResourceback to summary
public XAResource getXAResource() throws SQLException

Implements javax.sql.XAConnection.getXAResource.

Doc from javax.sql.XAConnection.getXAResource.

Retrieves an XAResource object that the transaction manager will use to manage this XAConnection object's participation in a distributed transaction.

Returns:XAResource

the XAResource object

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs
isSameRMback to summary
public boolean isSameRM(XAResource xaRes) throws XAException

Implements javax.transaction.xa.XAResource.isSameRM.

Doc from javax.transaction.xa.XAResource.isSameRM.

This method is called to determine if the resource manager instance represented by the target object is the same as the resource manager instance represented by the parameter xares.

Parameters
xaRes:XAResource

An XAResource object whose resource manager instance is to be compared with the resource manager instance of the target object.

Returns:boolean

true if it's the same RM instance; otherwise false.

Annotations
@Override
Exceptions
XAException:
An error has occurred. Possible exception values are XAER_RMERR and XAER_RMFAIL.
prepareback to summary
public int prepare(Xid xid) throws XAException

Implements javax.transaction.xa.XAResource.prepare.

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

Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.

Parameters
xid:Xid

A global transaction identifier.

Returns:int

A value indicating the resource manager's vote on the outcome of the transaction. The possible values are: XA_RDONLY or XA_OK. If the resource manager wants to roll back the transaction, it should do so by raising an appropriate XAException in the prepare method.

Annotations
@Override
Exceptions
XAException:
An error has occurred. Possible exception values are: XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
recoverback to summary
public Xid[] recover(int flag) throws XAException

Implements javax.transaction.xa.XAResource.recover.

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

Obtains a list of prepared transaction branches from a resource manager. The transaction manager calls this method during recovery to obtain the list of transaction branches that are currently in prepared or heuristically completed states.

Parameters
flag:int

One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other flags are set in the parameter.

Returns:Xid[]

The resource manager returns zero or more XIDs of the transaction branches that are currently in a prepared or heuristically completed state. If an error occurs during the operation, the resource manager should throw the appropriate XAException.

Annotations
@Override
Exceptions
XAException:
An error has occurred. Possible values are XAER_RMERR, XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.
removeXAConnectionMappingback to summary
private static void removeXAConnectionMapping(Xid xid)
rollbackback to summary
public void rollback(Xid xid) throws XAException

Implements javax.transaction.xa.XAResource.rollback.

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

Informs the resource manager to roll back work done on behalf of a transaction branch.

Parameters
xid:Xid

A global transaction identifier.

Annotations
@Override
Exceptions
XAException:
An error has occurred.
setTransactionTimeoutback to summary
public boolean setTransactionTimeout(int arg0) throws XAException

Implements javax.transaction.xa.XAResource.setTransactionTimeout.

Doc from javax.transaction.xa.XAResource.setTransactionTimeout.

Sets the current transaction timeout value for this XAResource instance. Once set, this timeout value is effective until setTransactionTimeout is invoked again with a different value. To reset the timeout value to the default value used by the resource manager, set the value to zero. If the timeout operation is performed successfully, the method returns true; otherwise false. If a resource manager does not support explicitly setting the transaction timeout value, this method returns false.

Parameters
arg0:int

The transaction timeout value in seconds.

Returns:boolean

true if the transaction timeout value is set successfully; otherwise false.

Annotations
@Override
Exceptions
XAException:
An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.
startback to summary
public void start(Xid xid, int arg1) throws XAException

Implements javax.transaction.xa.XAResource.start.

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

Starts work on behalf of a transaction branch specified in xid. If TMJOIN is specified, the start applies to joining a transaction previously seen by the resource manager. If TMRESUME is specified, the start applies to resuming a suspended transaction specified in the parameter xid. If neither TMJOIN nor TMRESUME is specified and the transaction specified by xid has previously been seen by the resource manager, the resource manager throws the XAException exception with XAER_DUPID error code.

Parameters
xid:Xid

A global transaction identifier to be associated with the resource.

arg1:int

One of TMNOFLAGS, TMJOIN, or TMRESUME.

Annotations
@Override
Exceptions
XAException:
An error has occurred. Possible exceptions are XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_DUPID, XAER_OUTSIDE, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
switchToXidback to summary
private void switchToXid(Xid xid) throws XAException