You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Daniel Stephens <da...@gmail.com> on 2007/04/02 18:36:26 UTC

Re: connection pool

sorry if someone has already mentioned this, but you will probably have to
add the testOnborrow Parameter. So that also means you have to use the
ValidationQuery, etc... but it(the pool) should try to restablish a
connection at that point.

testOnBorrow will cause some more overhead, but it might resolve your
problem.

here's an example..

<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@<host>:<port>:<sid></value>
</parameter>
<parameter>
<name>username</name>
<value>john</value>
</parameter>
<parameter>
<name>password</name>
<value>doe</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>5</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>5</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>validationQuery</name>
<value>select count(*) from dual</value>
</parameter>
<parameter>
 <name>testOnBorrow</name>
 <value>true</value>
</parameter>

On 3/19/07, Gioia, Michael <Mi...@childrens.harvard.edu> wrote:
>
> Hi, I'm new to tomcat and have a problem with keeping up the connection
> to the database thru the connection pool.
>
>
>
> Almost every weekend the database gets bumped and the java app that were
> running needs to have tomcat restarted to reconnect to the database thru
> the connection pool.  When we come in on Monday tomcat and the database
> are up and running, but the app will not connect to the database.
>
>
>
> Is there a way to reestablish the connection so our users don't have to
> wait until we come in on Monday to restart tomcat?
>
>
>
> Many Thanks,
>
> MG
>
>

Re: connection pool

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Martin Gainty wrote:
> MG--
> You want to make sure your abandoned connections are properly 
> re-cycled e.g.
> To configure a DBCP DataSource so that abandoned dB connections are 
> removed and recycled add the following paramater to the ResourceParams 
> configuration for your DBCP DataSource Resource:
>
>
>                 <parameter>
>              <name>removeAbandoned</name>
>              <value>true</value>
>            </parameter>
yeah, the problem with this is that the algorithm for the "abandoned" 
connections is quite fishy, you'll pretty much have to reach max 
connections before any abandoned removal is done.
but yes, that is what you need,

also set logAbandoned="true" so that you can get some info where your 
"leak" is
Filip
>
>
> http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html 
>
>
> MG --
>
> ----- Original Message ----- From: "Daniel Stephens" <da...@gmail.com>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Monday, April 02, 2007 12:36 PM
> Subject: Re: connection pool
>
>
>> sorry if someone has already mentioned this, but you will probably 
>> have to
>> add the testOnborrow Parameter. So that also means you have to use the
>> ValidationQuery, etc... but it(the pool) should try to restablish a
>> connection at that point.
>>
>> testOnBorrow will cause some more overhead, but it might resolve your
>> problem.
>>
>> here's an example..
>>
>> <parameter>
>> <name>factory</name>
>> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>> </parameter>
>> <parameter>
>> <name>driverClassName</name>
>> <value>oracle.jdbc.driver.OracleDriver</value>
>> </parameter>
>> <parameter>
>> <name>url</name>
>> <value>jdbc:oracle:thin:@<host>:<port>:<sid></value>
>> </parameter>
>> <parameter>
>> <name>username</name>
>> <value>john</value>
>> </parameter>
>> <parameter>
>> <name>password</name>
>> <value>doe</value>
>> </parameter>
>> <parameter>
>> <name>maxActive</name>
>> <value>5</value>
>> </parameter>
>> <parameter>
>> <name>maxIdle</name>
>> <value>5</value>
>> </parameter>
>> <parameter>
>> <name>maxWait</name>
>> <value>-1</value>
>> </parameter>
>> <parameter>
>> <name>removeAbandoned</name>
>> <value>true</value>
>> </parameter>
>> <parameter>
>> <name>validationQuery</name>
>> <value>select count(*) from dual</value>
>> </parameter>
>> <parameter>
>> <name>testOnBorrow</name>
>> <value>true</value>
>> </parameter>
>>
>> On 3/19/07, Gioia, Michael <Mi...@childrens.harvard.edu> wrote:
>>>
>>> Hi, I'm new to tomcat and have a problem with keeping up the connection
>>> to the database thru the connection pool.
>>>
>>>
>>>
>>> Almost every weekend the database gets bumped and the java app that 
>>> were
>>> running needs to have tomcat restarted to reconnect to the database 
>>> thru
>>> the connection pool.  When we come in on Monday tomcat and the database
>>> are up and running, but the app will not connect to the database.
>>>
>>>
>>>
>>> Is there a way to reestablish the connection so our users don't have to
>>> wait until we come in on Monday to restart tomcat?
>>>
>>>
>>>
>>> Many Thanks,
>>>
>>> MG
>>>
>>>
>>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.25/744 - Release Date: 4/3/2007 5:32 AM
>   


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


Re: connection pool

Posted by Martin Gainty <mg...@hotmail.com>.
MG--
You want to make sure your abandoned connections are properly re-cycled e.g.
To configure a DBCP DataSource so that abandoned dB connections are removed 
and recycled add the following paramater to the ResourceParams configuration 
for your DBCP DataSource Resource:


                 <parameter>
              <name>removeAbandoned</name>
              <value>true</value>
            </parameter>


http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html

MG --

----- Original Message ----- 
From: "Daniel Stephens" <da...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Monday, April 02, 2007 12:36 PM
Subject: Re: connection pool


> sorry if someone has already mentioned this, but you will probably have to
> add the testOnborrow Parameter. So that also means you have to use the
> ValidationQuery, etc... but it(the pool) should try to restablish a
> connection at that point.
>
> testOnBorrow will cause some more overhead, but it might resolve your
> problem.
>
> here's an example..
>
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
> <parameter>
> <name>driverClassName</name>
> <value>oracle.jdbc.driver.OracleDriver</value>
> </parameter>
> <parameter>
> <name>url</name>
> <value>jdbc:oracle:thin:@<host>:<port>:<sid></value>
> </parameter>
> <parameter>
> <name>username</name>
> <value>john</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value>doe</value>
> </parameter>
> <parameter>
> <name>maxActive</name>
> <value>5</value>
> </parameter>
> <parameter>
> <name>maxIdle</name>
> <value>5</value>
> </parameter>
> <parameter>
> <name>maxWait</name>
> <value>-1</value>
> </parameter>
> <parameter>
> <name>removeAbandoned</name>
> <value>true</value>
> </parameter>
> <parameter>
> <name>validationQuery</name>
> <value>select count(*) from dual</value>
> </parameter>
> <parameter>
> <name>testOnBorrow</name>
> <value>true</value>
> </parameter>
>
> On 3/19/07, Gioia, Michael <Mi...@childrens.harvard.edu> wrote:
>>
>> Hi, I'm new to tomcat and have a problem with keeping up the connection
>> to the database thru the connection pool.
>>
>>
>>
>> Almost every weekend the database gets bumped and the java app that were
>> running needs to have tomcat restarted to reconnect to the database thru
>> the connection pool.  When we come in on Monday tomcat and the database
>> are up and running, but the app will not connect to the database.
>>
>>
>>
>> Is there a way to reestablish the connection so our users don't have to
>> wait until we come in on Monday to restart tomcat?
>>
>>
>>
>> Many Thanks,
>>
>> MG
>>
>>
>