This is a JDBC Connection that encompasses the following three collaborators:
An XAResource, to which this class cedes control when a distributed transaction
is active. The XAResource is represented by a ConnectionXAResource object.
Each JRunDataSource knows of a single JDBCPool. That JDBCPool contains pools of these
JRunConnection objects. Upon receiving the request, the JDBC pool checks out a validated
JRunConnection from those available in the pool, and wraps it within a JRunConnectionHandle.
Before returning this Handle, the XADataSource implementation (JRunDataSource) determines
whether a distributed transaction is active. If so, it enlists the JRunConnection's XAResource
in the Transaction. It then returns the Handle to the original caller.
When the client closes the Handle, that Handle is disposed of. But the JRunConnection
is returned to its pool, available for further checkouts. If the JRunConnection's XAResource
is still active in a transaction, however, it will remain in the pool but will be unavailable
until the transaction either commits or rolls back. Eventually the TX will timeout, causing a
rollback and freeing such "locked" connections, at which time they are immediately available
to service more checkout requests.
Close and Error events are not handled explicitly, but propagated through ConnectionEvents
in accordance with the JDBC spec. Similarly, the JRunConnection, Handle, and DataSource
all implement the standard pooling mechanism defined in the specification.
- Author:
- PS Neville
- See Also:
- Serialized Form
JRunConnection
public JRunConnection(java.sql.Connection con,
ObjectPool pool)
isValid
public boolean isValid()
isTmControlled
public boolean isTmControlled()
setTmControlled
public void setTmControlled(boolean tmControlled)
closeAllResources
public void closeAllResources()
- Description copied from interface:
PooledObject
- Disassociate resource references from this object
- Specified by:
closeAllResources in interface PooledObject
closeAll
public void closeAll()
removeOpenStatement
public void removeOpenStatement(JRunStatement s)
clean
public boolean clean()
- Close any lingering Statements, ResutSets, and started XAResources
as long as we're not involved in a transaction. While in a transaction,
the JDBCManager relinquishes control over the Connection to the TM.
The timeout and expiration checks in the JDBCPool similarly submit to the TM.
- Specified by:
clean in interface PooledObject
touch
public void touch()
- Update the locked table in ObjectPool to prevent the object from timing out.
getPool
public ObjectPool getPool()
- Description copied from interface:
PooledObject
- Retrieve the pool containing this Object.
- Specified by:
getPool in interface PooledObject
- Following copied from interface:
jrunx.pool.PooledObject
- Returns:
- ObjectPool The pool that contains this object
getXAResource
public javax.transaction.xa.XAResource getXAResource()
throws java.sql.SQLException
getConnection
public java.sql.Connection getConnection()
throws java.sql.SQLException
getPhysicalConnection
public java.sql.Connection getPhysicalConnection()
addConnectionEventListener
public void addConnectionEventListener(javax.sql.ConnectionEventListener listener)
removeConnectionEventListener
public void removeConnectionEventListener(javax.sql.ConnectionEventListener listener)
sendCloseEvent
public void sendCloseEvent()
createStatement
public java.sql.Statement createStatement()
throws java.sql.SQLException
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql)
throws java.sql.SQLException
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql)
throws java.sql.SQLException
setAutoCommit
public void setAutoCommit(boolean autoCommit)
throws java.sql.SQLException
getAutoCommit
public boolean getAutoCommit()
throws java.sql.SQLException
commit
public void commit()
throws java.sql.SQLException
rollback
public void rollback()
throws java.sql.SQLException
close
public void close()
throws java.sql.SQLException
- Close the physical Connection.
isClosed
public boolean isClosed()
throws java.sql.SQLException
getMetaData
public java.sql.DatabaseMetaData getMetaData()
throws java.sql.SQLException
setReadOnly
public void setReadOnly(boolean readOnly)
throws java.sql.SQLException
isReadOnly
public boolean isReadOnly()
throws java.sql.SQLException
setCatalog
public void setCatalog(java.lang.String catalog)
throws java.sql.SQLException
getCatalog
public java.lang.String getCatalog()
throws java.sql.SQLException
setTransactionIsolation
public void setTransactionIsolation(int level)
throws java.sql.SQLException
getTransactionIsolation
public int getTransactionIsolation()
throws java.sql.SQLException
getWarnings
public java.sql.SQLWarning getWarnings()
throws java.sql.SQLException
clearWarnings
public void clearWarnings()
throws java.sql.SQLException
createStatement
public java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
getTypeMap
public java.util.Map getTypeMap()
throws java.sql.SQLException
setTypeMap
public void setTypeMap(java.util.Map map)
throws java.sql.SQLException
getUsername
public java.lang.String getUsername()
setUsername
public void setUsername(java.lang.String username)
getPassword
public java.lang.String getPassword()
setPassword
public void setPassword(java.lang.String password)
isConnectionError
public boolean isConnectionError()
setConnectionError
public void setConnectionError(boolean connectionError)
toString
public java.lang.String toString()
Copyright � 2002 Macromedia Corporation. All Rights Reserved.