Methods Summary |
---|
synchronized void | checkXact()Check the TransactionContext. If the current thread is in a
transaction, and the Connection is not participating in a
transaction; the Connection should register a resource with
the current thread's transaction. If the current thread is
in a transaction, and the Connection is participating in a
transaction; the thread's transaction and the Connection's
transaction must be the same transaction. Anything else is
an error.
/* RESOLVE: Need to reimplement this
* for CMP environment if any
Transaction tran;
try
{
tran = ThreadContext.transactionContext().getTransaction();
}
catch (SystemException ex)
{
tran = null;
}
if (tran == null)
{
if (this.transaction != null)
{
throw new SQLException("Thread is no longer in transaction."); // NOI18N
}
else
{
// No transaction.
return;
}
}
else if (this.transaction == null)
{
// This is a new transaction.
this.transaction = tran;
this.resource = new ForteJDBCResource(this);
try
{
TranManager tm = ThreadContext.partition().getTranManager();
tm.enlistResource(this.resource);
this.setAutoCommit(false);
}
catch (SQLException ex)
{
}
catch (Throwable ex)
{
// XXX This shouldn't happen. XXX
}
this.connectionManager.associateXact(tran, this);
}
else if (!tran.equals(this.transaction))
{
throw new SQLException("Wrong Transaction."); // NOI18N
}
else
{
// Connection and thread are in the same transaction.
return;
}
*/
|
public synchronized void | clearWarnings()
try {
this.connection.clearWarnings();
} catch (SQLException se) {
throw se;
}
|
private void | clearXact()Clear this ConnectionImpl of any knowledge of a transaction.
Also informs the parent ConnectionManager to clear its knowledge
of the transaction as well.
logger.finest("sqlstore.connectionimpl.clearxact"); // NOI18N
try {
if (this.freePending) {
this.freePending = false;
if (this.pooled) {
this.connectionManager.disassociateXact(this.transaction, this, true);
logger.finest("sqlstore.connectionimpl.pendingdisassocxact"); // NOI18N
} else {
this.connectionManager.disassociateXact(this.transaction, this, false);
// Make sure the last things done are the only things
// that can throw exceptions.
this.connection.close();
logger.finest("sqlstore.connectionimpl.clearxact.close"); // NOI18N
}
} else {
this.connectionManager.disassociateXact(this.transaction, this, false);
logger.finest("sqlstore.connectionimpl.clearxact.disassocxact"); // NOI18N
}
this.connection.setAutoCommit(true);
} catch (SQLException ex) {
// XXX Need to recover from a bad connection. XXX
} finally {
// this.resource = null;
this.transaction = null;
}
|
public synchronized void | close()
if (EJBHelper.isManaged()) {
logger.finest("sqlstore.connectionimpl.close"); // NOI18N
// ignore - this can happen in test 'ejb' only
return;
}
closeInternal();
|
private synchronized void | closeInternal()
boolean debug = logger.isLoggable(Logger.FINEST);
ConnectionImpl conn = (ConnectionImpl) this;
if (debug) {
logger.finest("sqlstore.connectionimpl.close_arg",conn); // NOI18N
}
try {
conn.connectionManager.busyList.removeFromList((Linkable) conn);
if (conn.xactPending() == true) {
conn.setFreePending(true);
if (debug) {
logger.finest("sqlstore.connectionimpl.close.freepending"); // NOI18N
}
} else if ((conn.getPooled() == true) && (conn.connectionManager.shutDownPending == false)) {
conn.connectionManager.freeList.insertAtTail((Linkable) conn);
if (debug) {
logger.finest("sqlstore.connectionimpl.close.putfreelist"); // NOI18N
}
} else {
if (EJBHelper.isManaged()) {
// RESOLVE: do we need it here?
this.connection.close();
if (debug) {
logger.finest("sqlstore.connectionimpl.close.exit"); // NOI18N
}
} else {
// Save reference to this connection and close it only when
// another free becomes available. This reduces time to
// get a new connection.
this.connectionManager.replaceFreeConnection(this);
if (debug) {
logger.finest("sqlstore.connectionimpl.close.replaced"); // NOI18N
}
}
}
} catch (SQLException se) {
throw se;
}
|
public synchronized void | commit()
try {
this.connection.commit();
if (this.freePending) {
if (this.connectionManager.shutDownPending) {
try {
this.connection.close();
logger.finest("sqlstore.connectionimpl.commit"); // NOI18N
} catch (SQLException se) {
;
}
} else {
this.freePending = false;
this.connectionManager.freeList.insertAtTail(this);
}
}
if (EJBHelper.isManaged()) {
// this is for use with test 'ejb' only.
closeInternal();
}
} catch (SQLException se) {
throw se;
}
|
public synchronized java.sql.Statement | createStatement()
StatementImpl fstmt;
try {
this.checkXact();
fstmt = new StatementImpl(this, this.connection.createStatement());
} catch (SQLException se) {
throw se;
}
return ((Statement) fstmt);
|
public java.sql.Statement | createStatement(int resultSetType, int resultSetConcurrency)
return (null);
|
public synchronized java.sql.Statement | createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throw new UnsupportedOperationException();
|
protected void | finalize()
try {
this.connection.close();
logger.finest("sqlstore.connectionimpl.finalize"); // NOI18N
} catch (SQLException se) {
;
}
|
public synchronized boolean | getAutoCommit()
try {
return (this.connection.getAutoCommit());
} catch (SQLException se) {
throw se;
}
|
public synchronized java.lang.String | getCatalog()
try {
return (this.connection.getCatalog());
} catch (SQLException se) {
throw se;
}
|
synchronized boolean | getFreePending()Get the value of the free-pending attribute.
return (this.freePending);
|
public synchronized int | getHoldability()
throw new UnsupportedOperationException();
|
public synchronized java.sql.DatabaseMetaData | getMetaData()
try {
return (this.connection.getMetaData());
} catch (SQLException se) {
throw se;
}
|
public com.sun.jdo.spi.persistence.utility.Linkable | getNext()Get the next ConnectionImpl in a chain.
return (this.next);
|
synchronized boolean | getPooled()Indicates whether this ConnectionImpl is pooled.
return (this.pooled);
|
public com.sun.jdo.spi.persistence.utility.Linkable | getPrevious()Get the previous ConnectionImpl in a chain.
return (this.previous);
|
public synchronized int | getTransactionIsolation()
try {
return (this.connection.getTransactionIsolation());
} catch (SQLException se) {
throw se;
}
|
public synchronized java.util.Map | getTypeMap()
try {
return (this.connection.getTypeMap());
} catch (SQLException se) {
throw se;
}
|
synchronized java.lang.String | getURL()Get the url for this ConnectionImpl object.
return this.url;
|
synchronized java.lang.String | getUserName()Get the user name for this ConnectionImpl object.
return this.userName;
|
public synchronized java.sql.SQLWarning | getWarnings()
try {
return (this.connection.getWarnings());
} catch (SQLException se) {
throw se;
}
|
public synchronized void | internalCommit()Used by TransactionImpl to commit the transaction on this
Connection. Also disassociates this Connection from the
transaction. Throws ... (javax.transaction.xa.XAException(XA_RBROLLBACK))
on commit error.
logger.finest("sqlstore.connectionimpl.internalcommit"); // NOI18N
try {
this.connection.commit();
} catch (Exception e1) {
try {
this.connection.rollback();
} catch (Exception e2) {
// XXX Try to recover from bad connection. XXX
} finally {
this.clearXact();
}
throw new JDODataStoreException(null, e1); //XAException(XAException.XA_RBROLLBACK);
} finally {
this.clearXact();
}
|
public synchronized void | internalRollback()Used by TransactionImpl to rollback the transaction on this
Connection. Also disassociates this Connection from the
transaction.
logger.finest("sqlstore.connectionimpl.internalrollback"); // NOI18N
try {
this.connection.rollback();
} catch (Exception e1) {
// XXX Try to recover from bad connection. XXX
} finally {
this.clearXact();
}
|
public synchronized boolean | isClosed()
try {
return (this.connection.isClosed());
} catch (SQLException se) {
throw se;
}
|
public synchronized boolean | isReadOnly()
try {
return (this.connection.isReadOnly());
} catch (SQLException se) {
throw se;
}
|
public synchronized java.lang.String | nativeSQL(java.lang.String sql)
try {
return (this.connection.nativeSQL(sql));
} catch (SQLException se) {
throw se;
}
|
public synchronized java.sql.CallableStatement | prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throw new UnsupportedOperationException();
|
public java.sql.CallableStatement | prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
return (null);
|
public synchronized java.sql.CallableStatement | prepareCall(java.lang.String sql)
CallableStatementImpl fcstmt;
try {
this.checkXact();
fcstmt = new CallableStatementImpl(this,
this.connection.prepareCall(sql));
return ((CallableStatement) fcstmt);
} catch (SQLException se) {
throw se;
}
|
public synchronized java.sql.PreparedStatement | prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throw new UnsupportedOperationException();
|
public synchronized java.sql.PreparedStatement | prepareStatement(java.lang.String sql, int autoGeneratedKeys)
throw new UnsupportedOperationException();
|
public synchronized java.sql.PreparedStatement | prepareStatement(java.lang.String sql, int[] columnIndexes)
throw new UnsupportedOperationException();
|
public synchronized java.sql.PreparedStatement | prepareStatement(java.lang.String sql, java.lang.String[] columnNames)
throw new UnsupportedOperationException();
|
public java.sql.PreparedStatement | prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
return (null);
|
public synchronized java.sql.PreparedStatement | prepareStatement(java.lang.String sql)
PreparedStatementImpl fpstmt;
try {
this.checkXact();
fpstmt = new PreparedStatementImpl(this,
this.connection.prepareStatement(sql));
} catch (SQLException se) {
throw se;
}
return ((PreparedStatement) fpstmt);
|
protected void | release()Called by ConnectionManager to close old connection when a new free connection
becomes available
try {
this.connection.close();
} catch (SQLException se) {
// ignore
}
logger.finest("sqlstore.connectionimpl.close.connrelease"); // NOI18N
|
public synchronized void | releaseSavepoint(java.sql.Savepoint savepoint)
throw new UnsupportedOperationException();
|
public synchronized void | rollback()
logger.finest("sqlstore.connectionimpl.rollback"); // NOI18N
try {
this.connection.rollback();
if (this.freePending) {
if (this.connectionManager.shutDownPending) {
this.connection.close();
logger.finest("sqlstore.connectionimpl.rollback.close"); // NOI18N
} else {
this.freePending = false;
this.connectionManager.freeList.insertAtTail(this);
}
}
if (EJBHelper.isManaged()) {
// this is for use with test 'ejb' only.
closeInternal();
}
} catch (SQLException se) {
throw se;
}
|
public synchronized void | rollback(java.sql.Savepoint savepoint)
throw new UnsupportedOperationException();
|
public synchronized void | setAutoCommit(boolean autoCommit)
try {
this.connection.setAutoCommit(autoCommit);
} catch (SQLException se) {
throw se;
}
|
public synchronized void | setCatalog(java.lang.String catalog)
try {
this.connection.setCatalog(catalog);
} catch (SQLException se) {
throw se;
}
|
synchronized void | setFreePending(boolean freePending)Mark the Connection free-pending. A Connection gets into this
state only if it is freed while still participating in a transaction.
this.freePending = freePending;
|
public synchronized void | setHoldability(int holdability)
throw new UnsupportedOperationException();
|
public void | setNext(com.sun.jdo.spi.persistence.utility.Linkable conn)Hook a ConnectionImpl to a chain.
this.next = conn;
|
synchronized void | setPooled(boolean flag)Mark this ConnectionImpl as pooled.
this.pooled = flag;
|
public void | setPrevious(com.sun.jdo.spi.persistence.utility.Linkable conn)Hook a ConnectionImpl to a chain.
this.previous = conn;
|
public synchronized void | setReadOnly(boolean readOnly)
try {
this.connection.setReadOnly(readOnly);
} catch (SQLException se) {
throw se;
}
|
public synchronized java.sql.Savepoint | setSavepoint()
throw new UnsupportedOperationException();
|
public synchronized java.sql.Savepoint | setSavepoint(java.lang.String name)
throw new UnsupportedOperationException();
|
public synchronized void | setTransactionIsolation(int level)
try {
this.connection.setTransactionIsolation(level);
} catch (SQLException se) {
throw se;
}
|
public synchronized void | setTypeMap(java.util.Map map)
try {
this.connection.setTypeMap(map);
} catch (SQLException se) {
throw se;
}
|
public synchronized java.lang.String | toString()Return a string representation of this ConnectionImpl object.
int xactIsolation = 0;
String buffer = "Connect@"; // NOI18N
String strTran = (this.transaction == null) ?
" NULL" : this.transaction.toString(); // NOI18N
int hash = this.hashCode();
try {
xactIsolation = this.getTransactionIsolation();
} catch (SQLException ex) {
xactIsolation = -1;
}
buffer = buffer + hash + "\n" + // NOI18N
" pooled = " + this.pooled + "\n" + // NOI18N
" freePending = " + this.freePending + "\n" + // NOI18N
" xactIsolation = " + xactIsolation + "\n" + // NOI18N
" Tran = " + strTran + "\n"; // NOI18N
return buffer;
|
synchronized boolean | xactPending()Indicates whether this Connection is participating in a transaction.
return ((this.transaction != null) ? true : false);
|