package com.arjuna.ats.internal.jdbc;
import javax.transaction.RollbackException;
import javax.transaction.Status;
import javax.transaction.SystemException;
A transactional JDBC connection. This wraps the real connection and
registers it with the transaction at appropriate times to ensure that all
worked performed by it may be committed or rolled back.
Once a connection is used within a transaction, that instance is bound to
that transaction for the duration. It can be used by any number of threads,
as long as they all have the same notion of the "current" transaction. When
the transaction terminates, the connection is freed for use in another
transaction.
Applications must not use this class directly.
- Author(s):
- Mark Little (mark@arjuna.com)
- Version:
- $Id: ConnectionImple.java 2342 2006-03-30 13:06:17Z $
- Since:
- JTS 2.0.
if ((dynamic == null) || (dynamic.equals("")))
this(dbName, user, passwd, null);
jdbcLogger.logger.trace("ConnectionImple.ConnectionImple ( " + dbName + ", " + user
+ ", " + passwd + ", " + dynamic + " )");
if ((dynamic == null) || (dynamic.equals("")))
Not allowed if within a transaction.
ConnectionManager.remove(this);
javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager
javax.transaction.Transaction tx = tm.getTransaction();
boolean delayClose = false;
Can only set readonly before we use the connection in a given
transaction!
- Returns:
- the Arjuna specific recovery connection information. This should
not be used by anything other than Arjuna.
int resultSetConcurrency, int resultSetHoldability) throws SQLException
int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Returns:
- the XAResource associated with the current XAConnection.
Remove this connection so that we have to get another one when asked.
Some drivers allow connections to be reused once any transactions have
finished with them.
.getTransaction() != null)
Whenever a JDBC call is invoked on us we get an XAResource and try to
register it with the transaction. If the same thread causes this to
happen many times within the same transaction then we will currently
attempt to get and register many redundant XAResources for it. The JTA
implementation will detect this and ignore all but the first for each
thread. However, a further optimisation would be to trap such calls here
and not do a registration at all. This would require the connection
object to be informed whenever a transaction completes so that it could
flush its cache of XAResources though.
if (theConnection != null)
javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager
javax.transaction.Transaction tx = tm.getTransaction();
"ConnectionImple.registerDatabase - "
catch (RollbackException e1)
catch (SystemException e2)
javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager
javax.transaction.Transaction tx = tm.getTransaction();
if (tx.getStatus() != Status.STATUS_ACTIVE)