Package com.impossibl.postgres.jdbc.xa
Class PGXAConnection
- java.lang.Object
-
- com.impossibl.postgres.jdbc.PGPooledConnection
-
- com.impossibl.postgres.jdbc.xa.PGXAConnection
-
- All Implemented Interfaces:
javax.sql.PooledConnection,javax.sql.XAConnection,javax.transaction.xa.XAResource
public class PGXAConnection extends PGPooledConnection implements javax.sql.XAConnection, javax.transaction.xa.XAResource
The PostgreSQL implementation ofXAConnectionandXAResource. This implementation doesn't support transaction interleaving (see JTA specification, section 3.4.4) and suspend/resume. Two-phase commit requires PostgreSQL server version 8.1 or higher.
-
-
Constructor Summary
Constructors Constructor Description PGXAConnection(PGDirectConnection conn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommit(javax.transaction.xa.Xid xid, boolean onePhase)voidend(javax.transaction.xa.Xid xid, int flags)Preconditions: 1.voidforget(javax.transaction.xa.Xid xid)Does nothing, since we don't do heuristics,java.sql.ConnectiongetConnection()intgetTransactionTimeout()We don't do transaction timeouts.javax.transaction.xa.XAResourcegetXAResource()booleanisSameRM(javax.transaction.xa.XAResource xares)intprepare(javax.transaction.xa.Xid xid)Preconditions: 1.javax.transaction.xa.Xid[]recover(int flag)Preconditions: 1.voidrollback(javax.transaction.xa.Xid xid)Preconditions: 1.booleansetTransactionTimeout(int seconds)We don't do transaction timeouts.voidstart(javax.transaction.xa.Xid xid, int flags)Preconditions: 1.-
Methods inherited from class com.impossibl.postgres.jdbc.PGPooledConnection
addConnectionEventListener, addStatementEventListener, close, createConnectionEvent, createStatementEvent, fireConnectionError, getConnectionHandle, removeConnectionEventListener, removeStatementEventListener
-
-
-
-
Constructor Detail
-
PGXAConnection
public PGXAConnection(PGDirectConnection conn) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-
Method Detail
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException- Specified by:
getConnectionin interfacejavax.sql.PooledConnection- Overrides:
getConnectionin classPGPooledConnection- Throws:
java.sql.SQLException
-
getXAResource
public javax.transaction.xa.XAResource getXAResource()
- Specified by:
getXAResourcein interfacejavax.sql.XAConnection
-
start
public void start(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.XAExceptionPreconditions: 1. flags must be one of TMNOFLAGS, TMRESUME or TMJOIN 2. xid != null 3. connection must not be associated with a transaction 4. the TM hasn't seen the xid before Implementation deficiency preconditions: 1. TMRESUME not supported. 2. if flags is TMJOIN, we must be in ended state, and xid must be the current transaction 3. unless flags is TMJOIN, previous transaction using the connection must be committed or prepared or rolled back Postconditions: 1. Connection is associated with the transaction- Specified by:
startin interfacejavax.transaction.xa.XAResource- Throws:
javax.transaction.xa.XAException
-
end
public void end(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.XAExceptionPreconditions: 1. Flags is one of TMSUCCESS, TMFAIL, TMSUSPEND 2. xid != null 3. Connection is associated with transaction xid Implementation deficiency preconditions: 1. Flags is not TMSUSPEND Postconditions: 1. connection is disassociated from the transaction.- Specified by:
endin interfacejavax.transaction.xa.XAResource- Throws:
javax.transaction.xa.XAException
-
prepare
public int prepare(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAExceptionPreconditions: 1. xid != null 2. xid is in ended state Implementation deficiency preconditions: 1. xid was associated with this connection Postconditions: 1. Transaction is prepared- Specified by:
preparein interfacejavax.transaction.xa.XAResource- Throws:
javax.transaction.xa.XAException
-
recover
public javax.transaction.xa.Xid[] recover(int flag) throws javax.transaction.xa.XAExceptionPreconditions: 1. flag must be one of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS or TMSTARTTRSCAN | TMENDRSCAN 2. if flag isn't TMSTARTRSCAN or TMSTARTRSCAN | TMENDRSCAN, a recovery scan must be in progress Postconditions: 1. list of prepared xids is returned- Specified by:
recoverin interfacejavax.transaction.xa.XAResource- Throws:
javax.transaction.xa.XAException
-
rollback
public void rollback(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAExceptionPreconditions: 1. xid is known to the RM or it's in prepared state Implementation deficiency preconditions: 1. xid must be associated with this connection if it's not in prepared state. Postconditions: 1. Transaction is rolled back and disassociated from connection- Specified by:
rollbackin interfacejavax.transaction.xa.XAResource- Throws:
javax.transaction.xa.XAException
-
commit
public void commit(javax.transaction.xa.Xid xid, boolean onePhase) throws javax.transaction.xa.XAException- Specified by:
commitin interfacejavax.transaction.xa.XAResource- Throws:
javax.transaction.xa.XAException
-
isSameRM
public boolean isSameRM(javax.transaction.xa.XAResource xares) throws javax.transaction.xa.XAException- Specified by:
isSameRMin interfacejavax.transaction.xa.XAResource- Throws:
javax.transaction.xa.XAException
-
forget
public void forget(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAExceptionDoes nothing, since we don't do heuristics,- Specified by:
forgetin interfacejavax.transaction.xa.XAResource- Throws:
javax.transaction.xa.XAException
-
getTransactionTimeout
public int getTransactionTimeout()
We don't do transaction timeouts. Just returns 0.- Specified by:
getTransactionTimeoutin interfacejavax.transaction.xa.XAResource
-
setTransactionTimeout
public boolean setTransactionTimeout(int seconds)
We don't do transaction timeouts. Returns false.- Specified by:
setTransactionTimeoutin interfacejavax.transaction.xa.XAResource
-
-