You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by S Ahmed <sa...@gmail.com> on 2012/04/04 13:08:39 UTC

jdbc pool properties

My db connections seem to be lost after an extended period of inactivity
(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"/>


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

I guess what I need is a minActive setting then?

Re: jdbc pool properties

Posted by Pid <pi...@pidster.com>.
On 04/04/2012 12:08, S Ahmed wrote:
> My db connections seem to be lost after an extended period of inactivity
> (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"/>
> 
> 
> Is it the removedAbonded and abandonedTimeout?  Does it mean "after 60
> seconds, remove the connection from the pool?
> 
> I guess what I need is a minActive setting then?

Do you have a connection validation query and test set?

E.g. testOnBorrow=true?


p


-- 

[key:62590808]


Re: jdbc pool properties

Posted by S Ahmed <sa...@gmail.com>.
Daniel,

Your suggestion seems to have worked so far, thanks!

testOnBorrow="true" and "validationQuery=SELECT 1"

On Wed, Apr 4, 2012 at 8:46 AM, Daniel Mikusa <dm...@vmware.com> wrote:

>
>
> ----- 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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: jdbc pool properties

Posted by Filip Hanik Mailing Lists <de...@hanik.com>.
> There are some databases that do go in and periodically kill off
> connections, aside from the Tomcat settings.

you may want to explore the maxAge option for this, as we can disconnect and create new connections before the DB does kills it as long lived

----- Original Message -----
> From: "Barry L Propes" <ba...@citi.com>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Wednesday, April 4, 2012 7:53:26 AM
> Subject: RE: jdbc pool properties
> 
> 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:dmikusa@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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 

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


RE: jdbc pool properties

Posted by "Propes, Barry L " <ba...@citi.com>.
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:dmikusa@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


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


Re: jdbc pool properties

Posted by S Ahmed <sa...@gmail.com>.
I'm using tomcat 7, in a spring mvc application.  The properties is in my
spring-context.xml file.

 <bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"
destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost/mydb"/>
        <property name="username" value="testuser"/>
        <property name="password" value="abc"/>

        <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"/>

        <property name="testOnBorrow" value="true" />
        <property name="validationQuery" value="SELECT 1" />

    </bean>

On Fri, Apr 6, 2012 at 2:09 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Daniel,
>
> On 4/4/12 8:46 AM, Daniel Mikusa wrote:
> > ----- Original Message -----
> >> My db connections seem to be lost after an extended period of
> >> inactivity (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).
>
> +1
>
> > See the following link for an explanation of those properties.
> >
> > https://commons.apache.org/dbcp/configuration.html
>
> - -1
>
> This is the wrong documentation for tomcat-pool. You're looking for
> http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
>
> On the other hand, there was no mention of a Tomcat version, what type
> of pool is actually being used (I inferred tomcat-pool from the
> subject line as well as the use of "tomcat.jdbc.pool.DataSource") and
> the use of <property> elements seems antiquated, so I must admit I'm a
> little confused.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk9/MWAACgkQ9CaO5/Lv0PCcOgCeJcRA6Oq2KcVSDE6vIAmQ+5Ji
> lJUAoL4QiLp1oZSBVkiaFYTrJTlK6Gkv
> =wFzD
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: jdbc pool properties

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel,

On 4/4/12 8:46 AM, Daniel Mikusa wrote:
> ----- Original Message -----
>> My db connections seem to be lost after an extended period of 
>> inactivity (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).

+1

> See the following link for an explanation of those properties.
> 
> https://commons.apache.org/dbcp/configuration.html

- -1

This is the wrong documentation for tomcat-pool. You're looking for
http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html

On the other hand, there was no mention of a Tomcat version, what type
of pool is actually being used (I inferred tomcat-pool from the
subject line as well as the use of "tomcat.jdbc.pool.DataSource") and
the use of <property> elements seems antiquated, so I must admit I'm a
little confused.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9/MWAACgkQ9CaO5/Lv0PCcOgCeJcRA6Oq2KcVSDE6vIAmQ+5Ji
lJUAoL4QiLp1oZSBVkiaFYTrJTlK6Gkv
=wFzD
-----END PGP SIGNATURE-----

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


Re: jdbc pool properties

Posted by Daniel Mikusa <dm...@vmware.com>.

----- 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org