|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.avalon.excalibur.datasource.AbstractJdbcConnection
public class AbstractJdbcConnection
The Connection object used in conjunction with the JdbcDataSource object.
Nested Class Summary | |
---|---|
private class |
AbstractJdbcConnection.ProxiedObject
|
Field Summary | |
---|---|
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 Summary | |
---|---|
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)
|
Method Summary | |
---|---|
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)
|
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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.
Constructor Detail |
---|
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.Method Detail |
---|
public void initialize()
public void enableLogging(org.apache.avalon.framework.logger.Logger log)
enableLogging
in interface org.apache.avalon.framework.logger.LogEnabled
enableLogging
in class org.apache.avalon.framework.logger.AbstractLogEnabled
public void setPool(org.apache.avalon.excalibur.pool.Pool pool)
PoolSettable
setPool
in interface PoolSettable
public void recycle()
recycle
in interface org.apache.avalon.excalibur.pool.Recyclable
public void setProxiedConnection(java.lang.Object proxy)
setProxiedConnection
in interface ProxiedJdbcConnection
public java.sql.Connection getConnection()
getConnection
in interface ProxiedJdbcConnection
public boolean isClosed() throws java.sql.SQLException
java.sql.SQLException
public void close() throws java.sql.SQLException
java.sql.SQLException
protected 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.Disposable
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public 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.InvocationHandler
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |