public class AbstractJdbcConnection extends org.apache.avalon.framework.logger.AbstractLogEnabled implements PoolSettable, org.apache.avalon.framework.activity.Disposable, ProxiedJdbcConnection
| Modifier and Type | Class and Description |
|---|---|
private class |
AbstractJdbcConnection.ProxiedObject |
| Modifier and Type | Field and Description |
|---|---|
private java.util.List |
m_allocatedStatements
Contains Statements created on the original jdbc connection
between a
JdbcDataSource.getConnection() and Connection.close(). |
protected java.sql.Connection |
m_connection |
protected boolean |
m_encounteredError
Flag to keep track of whether or not an error has been thrown since the last
time the DB was pinged.
|
protected long |
m_lastUsed |
private static java.util.Map |
m_methods |
protected org.apache.avalon.excalibur.pool.Pool |
m_pool |
private java.lang.Object |
m_proxy |
protected int |
m_testAge
The maximum time since a connection was last used before it will be pinged.
|
protected java.sql.SQLException |
m_testException |
protected java.sql.PreparedStatement |
m_testStatement |
| Constructor and Description |
|---|
AbstractJdbcConnection(java.sql.Connection connection,
boolean oradb)
Deprecated.
Use the version with keepAlive specified
|
AbstractJdbcConnection(java.sql.Connection connection,
java.lang.String keepAlive) |
AbstractJdbcConnection(java.sql.Connection connection,
java.lang.String keepAlive,
int keepAliveAge) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearAllocatedStatements()
Closes statements that were registered and removes all
statements from the list of allocated ones.
|
void |
close() |
void |
dispose() |
void |
enableLogging(org.apache.avalon.framework.logger.Logger log) |
boolean |
equals(java.lang.Object obj) |
java.sql.Connection |
getConnection() |
void |
initialize() |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args) |
boolean |
isClosed() |
void |
recycle() |
protected void |
registerAllocatedStatement(java.sql.Statement stmt)
Adds the statement to the list of this connection.
|
void |
setPool(org.apache.avalon.excalibur.pool.Pool pool)
Set the pool that will be used to recycle.
|
void |
setProxiedConnection(java.lang.Object proxy) |
protected java.sql.Connection m_connection
private java.lang.Object m_proxy
protected org.apache.avalon.excalibur.pool.Pool m_pool
protected boolean m_encounteredError
protected int m_testAge
protected java.sql.PreparedStatement m_testStatement
protected java.sql.SQLException m_testException
protected long m_lastUsed
private static final java.util.Map m_methods
private final java.util.List m_allocatedStatements
JdbcDataSource.getConnection() and Connection.close(). The statements are registered using
registerAllocatedStatement(java.sql.Statement) and deallocated in
close(). LinkedList was chosen because access
to elements is sequential through Iterator and the number
of elements is not known in advance. Synchronization is
done on the Link instance itself.public AbstractJdbcConnection(java.sql.Connection connection,
boolean oradb)
public AbstractJdbcConnection(java.sql.Connection connection,
java.lang.String keepAlive)
connection - a driver specific JDBC connection to be wrapped.keepAlive - a query which will be used to check the statis of the connection after it
has been idle. A null value will cause the keep alive feature to
be disabled.public AbstractJdbcConnection(java.sql.Connection connection,
java.lang.String keepAlive,
int keepAliveAge)
connection - a driver specific JDBC connection to be wrapped.keepAlive - a query which will be used to check the status of the connection after it
has been idle. A null value will cause the keep alive feature to
be disabled.keepAliveAge - the maximum age in milliseconds since a connection was last
used before it must be pinged using the keepAlive query. Ignored
if keepAlive is null.public void initialize()
public void enableLogging(org.apache.avalon.framework.logger.Logger log)
enableLogging in interface org.apache.avalon.framework.logger.LogEnabledenableLogging in class org.apache.avalon.framework.logger.AbstractLogEnabledpublic void setPool(org.apache.avalon.excalibur.pool.Pool pool)
PoolSettablesetPool in interface PoolSettablepublic void recycle()
recycle in interface org.apache.avalon.excalibur.pool.Recyclablepublic void setProxiedConnection(java.lang.Object proxy)
setProxiedConnection in interface ProxiedJdbcConnectionpublic java.sql.Connection getConnection()
getConnection in interface ProxiedJdbcConnectionpublic boolean isClosed()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void close()
throws java.sql.SQLException
java.sql.SQLExceptionprotected void clearAllocatedStatements()
throws java.sql.SQLException
Holds m_allocatedStatements locked the whole time. This should not be a problem because connections are inherently single threaded objects and any attempt to use them from a different thread while it is being closed is a violation of the contract.
java.sql.SQLException - of the first Statement.close()protected void registerAllocatedStatement(java.sql.Statement stmt)
public void dispose()
dispose in interface org.apache.avalon.framework.activity.Disposablepublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
invoke in interface java.lang.reflect.InvocationHandlerjava.lang.Throwable