Top Fields Constructors Methods
org.apache.derby.client.net

public Class NetXAResource

extends Object
implements XAResource
Class Inheritance
All Implemented Interfaces
javax.transaction.xa.XAResource
Imports
java.net.InetAddress, .UnknownHostException, javax.sql.XAConnection, javax.transaction.xa.XAException, .XAResource, .Xid, org.apache.derby.client.ClientXid, org.apache.derby.client.am.ClientConnection, .SqlException, .ClientMessageId, .SqlCode, .Utils, .XaException, org.apache.derby.shared.common.reference.SQLState

Field Summary

Modifier and TypeField and Description
pack-priv NetXACallInfo[]
pack-priv NetConnection
pack-priv SqlException
private static final int
private boolean
pack-priv NetXAConnection
pack-priv static final ClientXid
private int
timeoutSeconds

The value of the transaction timeout in seconds.

pack-priv static final int
private static final int
private static final int
private static final int
private static final int
pack-priv static final int
private static final int
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
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.
onePhase
)

Implements javax.transaction.xa.XAResource.commit.

Commits the global transaction specified by xid.
private void
public void
end(Xid
A global transaction identifier that is the same as what was used previously in the start method.
xid
,
int
One of TMSUCCESS, TMFAIL, or TMSUSPEND
flags
)

Implements javax.transaction.xa.XAResource.end.

Ends the work performed on behalf of a transaction branch.

public void
forget(Xid
A global transaction identifier
xid
)

Implements javax.transaction.xa.XAResource.forget.

Tell the resource manager to forget about a heuristically (MANUALLY) completed transaction branch.
private int

Returns:

XAException.XAER_RMFAIL for disconnect exception, XAException.XAER_RMERR for other exceptions.
getSqlExceptionXAErrorCode
(SqlException
SqlException to evaluate.
sqle
)

Get XAException.errorCode from SqlException For disconnect exception, return XAER_RMFAIL For other exceptions return XAER_RMERR For server side SQLExceptions during XA operations the errorCode has already been determined and wrapped in an XAException for return to the client.

public int

Returns:

the transaction timeout value in seconds. If the returned value is equal to Integer.MAX_VALUE it means no timeout.
getTransactionTimeout
()

Implements javax.transaction.xa.XAResource.getTransactionTimeout.

Obtain the current transaction timeout value set for this XAResource instance.
private String
private String
getXAFuncStr(int xaFunc)

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 boolean
public int

Returns:

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.
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.
private String
public Xid[]

Returns:

The resource manager returns zero or more XIDs for the transaction branches that are currently in a prepared or heuristically completed state. If an error occurs during the operation, the resource manager should raise the appropriate XAException.
recover
(int
One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other flags are set in flags.
flag
)

Implements javax.transaction.xa.XAResource.recover.

Obtain a list of prepared transaction branches from a resource manager.
public void
rollback(Xid
A global transaction identifier
xid
)

Implements javax.transaction.xa.XAResource.rollback.

Inform the resource manager to roll back work done on behalf of a transaction branch
public void
public boolean

Returns:

true if transaction timeout value is set successfully; otherwise false.
setTransactionTimeout
(int
the transaction timeout value in seconds. Value of 0 means the reasource manager's default value. Value of Integer.MAX_VALUE means no timeout.
seconds
)

Implements javax.transaction.xa.XAResource.setTransactionTimeout.

Set the current transaction timeout value for this XAResource instance.
private void
setXaStateForXAException(int
// return code from XAException
rc
)

Reset the transaction branch association state to XA_T0_NOT_ASSOCIATED for XAER_RM* and XA_RB* Exceptions.

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

Implements javax.transaction.xa.XAResource.start.

Start work on behalf of a transaction branch specified in xid
private void
protected int
xaRetValErrorAccumSQL(NetXACallInfo callInfo, int currentRC)

public static boolean
xidsEqual(Xid xid1, Xid xid2)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callInfoArray_back to summary
pack-priv NetXACallInfo[] callInfoArray_
conn_back to summary
pack-priv NetConnection conn_
exceptionsOnXAback to summary
pack-priv SqlException exceptionsOnXA
INITIAL_CALLINFO_ELEMENTSback to summary
private static final int INITIAL_CALLINFO_ELEMENTS
keepIsolationLevelback to summary
private boolean keepIsolationLevel
netXAConn_back to summary
pack-priv NetXAConnection netXAConn_
nullXidback to summary
pack-priv static final ClientXid nullXid
timeoutSecondsback to summary
private int timeoutSeconds

The value of the transaction timeout in seconds.

XAFUNC_COMMITback to summary
pack-priv static final int XAFUNC_COMMIT
XAFUNC_ENDback to summary
private static final int XAFUNC_END
XAFUNC_FORGETback to summary
private static final int XAFUNC_FORGET
XAFUNC_PREPAREback to summary
private static final int XAFUNC_PREPARE
XAFUNC_RECOVERback to summary
private static final int XAFUNC_RECOVER
XAFUNC_ROLLBACKback to summary
pack-priv static final int XAFUNC_ROLLBACK
XAFUNC_STARTback to summary
private static final int XAFUNC_START
XAFUNCSTR_COMMITback to summary
private static final String XAFUNCSTR_COMMIT
XAFUNCSTR_ENDback to summary
private static final String XAFUNCSTR_END
XAFUNCSTR_FORGETback to summary
private static final String XAFUNCSTR_FORGET
XAFUNCSTR_NONEback to summary
private static final String XAFUNCSTR_NONE
XAFUNCSTR_PREPAREback to summary
private static final String XAFUNCSTR_PREPARE
XAFUNCSTR_RECOVERback to summary
private static final String XAFUNCSTR_RECOVER
XAFUNCSTR_ROLLBACKback to summary
private static final String XAFUNCSTR_ROLLBACK
XAFUNCSTR_STARTback to summary
private static final String XAFUNCSTR_START

Constructor Detail

NetXAResourceback to summary
public NetXAResource(XAConnection xaconn, NetXAConnection conn)

Method Detail

commitback to summary
public void commit(Xid xid, boolean onePhase) 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

onePhase:boolean

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

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.

connectionClosedFailureback to summary
private void connectionClosedFailure() throws XAException
endback to summary
public void end(Xid xid, int flags) throws XAException

Implements javax.transaction.xa.XAResource.end.

Ends the work performed on behalf of a transaction branch. The resource manager dissociates the XA resource from the transaction branch specified and let the transaction be completed.

If TMSUSPEND is specified in flags, the transaction branch is temporarily suspended in incomplete state. The transaction context is in suspened state and must be resumed via start 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 what was used previously in the start method.

flags:int

One of TMSUCCESS, TMFAIL, or TMSUSPEND

Exceptions
XAException:
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) throws XAException

Implements javax.transaction.xa.XAResource.forget.

Tell the resource manager to forget about a heuristically (MANUALLY) completed transaction branch.

Parameters
xid:Xid

A global transaction identifier

Exceptions
XAException:
An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
getSqlExceptionXAErrorCodeback to summary
private int getSqlExceptionXAErrorCode(SqlException sqle)

Get XAException.errorCode from SqlException For disconnect exception, return XAER_RMFAIL For other exceptions return XAER_RMERR For server side SQLExceptions during XA operations the errorCode has already been determined and wrapped in an XAException for return to the client. see EmbedXAResource.wrapInXAException

Parameters
sqle:SqlException

SqlException to evaluate.

Returns:int

XAException.XAER_RMFAIL for disconnect exception, XAException.XAER_RMERR for other exceptions.

getTransactionTimeoutback to summary
public int getTransactionTimeout() throws XAException

Implements javax.transaction.xa.XAResource.getTransactionTimeout.

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

Returns:int

the transaction timeout value in seconds. If the returned value is equal to Integer.MAX_VALUE it means no timeout.

Exceptions
XAException:

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

An error has occurred. Possible exception values are XAER_RMERR and XAER_RMFAIL.

getXAExceptionTextback to summary
private String getXAExceptionText(int rc)
getXAFuncStrback to summary
private String getXAFuncStr(int xaFunc)
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.

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

Implements 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.

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

Implements javax.transaction.xa.XAResource.recover.

Obtain 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 flags.

Returns:Xid[]

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

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

Implements javax.transaction.xa.XAResource.rollback.

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

Parameters
xid:Xid

A global transaction identifier

Exceptions
XAException:
An error has occurred
setKeepCurrentIsolationLevelback to summary
public void setKeepCurrentIsolationLevel(boolean flag)
setTransactionTimeoutback to summary
public boolean setTransactionTimeout(int seconds) throws XAException

Implements javax.transaction.xa.XAResource.setTransactionTimeout.

Set 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 transaction timeout value to be set explicitly, this method returns false.

Parameters
seconds:int

the transaction timeout value in seconds. Value of 0 means the reasource manager's default value. Value of Integer.MAX_VALUE means no timeout.

Returns:boolean

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

Exceptions
XAException:
- An error has occurred. Possible exception values are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.
setXaStateForXAExceptionback to summary
private void setXaStateForXAException(int rc)

Reset the transaction branch association state to XA_T0_NOT_ASSOCIATED for XAER_RM* and XA_RB* Exceptions. All other exceptions leave the state unchanged

Parameters
rc:int

// return code from XAException

startback to summary
public synchronized void start(Xid xid, int flags) throws XAException

Implements javax.transaction.xa.XAResource.start.

Start work on behalf of a transaction branch specified in xid

Parameters
xid:Xid

A global transaction identifier to be associated with the resource

flags:int

One of TMNOFLAGS, TMJOIN, or TMRESUME

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.
throwXAExceptionback to summary
private void throwXAException(int rc) throws XAException
xaRetValErrorAccumSQLback to summary
protected int xaRetValErrorAccumSQL(NetXACallInfo callInfo, int currentRC)
xidsEqualback to summary
public static boolean xidsEqual(Xid xid1, Xid xid2)