You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2003/06/11 19:40:21 UTC
cvs commit: avalon-excalibur/datasource/src/java/org/apache/avalon/excalibur/datasource AbstractJdbcConnection.java
leif 2003/06/11 10:40:21
Modified: datasource/src/java/org/apache/avalon/excalibur/datasource
AbstractJdbcConnection.java
Log:
Fix the lastUsed code so that the keep alive query will no longer be called for
every query. It now once again works so that the keep alive query is only
performed if the connection has been idle for more than 5 seconds.
The commented out code to close a connection after being idle for an hour was
removed because it duplicates functionality from the pool.
Revision Changes Path
1.29 +9 -12 avalon-excalibur/datasource/src/java/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.java
Index: AbstractJdbcConnection.java
===================================================================
RCS file: /home/cvs/avalon-excalibur/datasource/src/java/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- AbstractJdbcConnection.java 17 Apr 2003 20:46:49 -0000 1.28
+++ AbstractJdbcConnection.java 11 Jun 2003 17:40:21 -0000 1.29
@@ -182,7 +182,6 @@
public void recycle()
{
- //m_lastUsed = System.currentTimeMillis(); // not accurate
m_testException = null;
try
{
@@ -214,16 +213,10 @@
}
long age = System.currentTimeMillis() - m_lastUsed;
-// Commenting out the hour check since it was to check an hour since last use, but since the
-// last-use time is not being updated anywhere, it has turned into "all connections expire after
-// an hour"
-// if( age > 1000 * 60 * 60 ) // over an hour?
-// {
-// this.dispose();
-// return true;
-// }
-
- if( m_testStatement != null && age > ( 5 * 1000 ) ) // over 5 seconds ago
+
+ // If the connection has not been used for 5 seconds, then make
+ // sure it is still alive.
+ if ( ( m_testStatement != null ) && ( age > ( 5 * 1000 ) ) )
{
if( getLogger().isDebugEnabled() )
{
@@ -249,6 +242,10 @@
public void close()
throws SQLException
{
+ // Always mark the time the connection was placed back in the pool
+ // as its last used time.
+ m_lastUsed = System.currentTimeMillis();
+
try
{
clearAllocatedStatements();
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org