There are some databases that do go in and periodically kill off connections, 
aside from the Tomcat settings.

In addition to testOnBorrow=true, I also had two other attributes, but not sure 
if Tomcat 7.0 uses them or not, as I'm on 6.0.29.

    testOnBorrow="true"
    timeBetweenEvictionRunsMillis="-1"
    minEvictableIdleTimeMillis="28800"



-----Original Message-----
From: Daniel Mikusa [mailto:dmik...@vmware.com]
Sent: Wednesday, April 04, 2012 7:46 AM
To: Tomcat Users List
Subject: Re: jdbc pool properties



----- Original Message -----
> My db connections seem to be lost after an extended period of
> inactivity

There could be a number of reasons that this occurs.  Perhaps a network issue 
is causing them to be disconnected or the database may be timing them out.  At 
any rate, it's not likely that the problem would be caused by the 
"removeAbandoned" / "abandonedTimeout" settings, unless you application is not 
properly returning connections to the connection pool.

  
https://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#Preventing_database_connection_pool_leaks


> (for a web application).  And the only way to get the connections to
> work again is to restart tomcat.
>
> My tomcat.jdbc.pool.Datasource settings have:
>
>  <property name="maxActive" value="100"/>
>         <property name="maxIdle" value="30"/>
>         <property name="maxWait" value="1000"/>
>         <property name="defaultAutoCommit" value="true"/>
>         <property name="removeAbandoned" value="true"/>
>         <property name="removeAbandonedTimeout" value="60"/>
>

You probably want to add testOnBorrow="true" and "validationQuery=SELECT 1"  
(or some other valid query for your DB).  See the following link for an 
explanation of those properties.

  https://commons.apache.org/dbcp/configuration.html

This will cause your connections to be validated prior to their use by your 
application.  Stale connections will be removed and replaced with new, working 
connections.

>
> Is it the removedAbonded and abandonedTimeout?  Does it mean "after 60
> seconds, remove the connection from the pool?

No.  See either of the links I've referenced above for an explanation of these 
settings.

>
> I guess what I need is a minActive setting then?
>

There's no "minActive" setting.  You have "minIdle", but I don't think that 
would help here.

Dan





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to