You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Paul Phillips <pa...@partitura.com> on 2002/08/27 06:04:08 UTC
sweeping stale connections - Commons DBCP and Tomcat 4.1.9
I'm using Tomcat 4.1.9. I have been having a problem with the DBCP jdbc
connection pool when used with MySQL. Apparently MySQL kills off stale
connections after an 8 hour period. According to Mark Matthews (developer
of the jdbc-mysql driver), I need to configure the pool to sweep out the
stale connections, and initiate new ones.
I have looked and looked in vain for documentation for DBCP that would
explain how to set the configuration in my Tomcat server.xml file (using
JNDI) that would enable this. I can't find anything. I've tried examining
the source of DBCP, but I'm afraid that I can't figure it out.
My Tomcat server.xml file uses this configuration below, which is right out
of:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-ho
wto.html
>>From what I can tell, there are other parameters that I can enter to force
the sweeping of stale connections. However, I don't know what they are, or
how to use them. If anyone can give me an example of the correct syntax
here, I would be very grateful, ( since my webapp dies every night, due to
this problem!)
Thanks --
Paul Phillips
(excerpt of server.xml...)
<Context path="/DBTest" docBase="DBTest"
debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30000</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>100</value>
</parameter>
<parameter>
<name>username</name>
<value>javauser</value>
</parameter>
<parameter>
<name>password</name>
<value>javadude</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest</value>
</parameter>
</ResourceParams>
</Context>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: sweeping stale connections - Commons DBCP and Tomcat 4.1.9
Posted by Paul Phillips <pa...@partitura.com>.
Hello -
> I had this same problem, appending "?autoReconnect=true" to your connect
> URL does work.
>
I tried this --
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
</parameter>
in my server.xml and it DOES work. Thanks to Glenn and Jay who suggested
it.
Regards,
Paul Phillips
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: sweeping stale connections - Commons DBCP and Tomcat 4.1.9
Posted by Glenn Nielsen <gl...@mail.more.net>.
I had this same problem, appending "?autoReconnect=true" to your connect URL does work.
Regards,
Glenn
Paul Phillips wrote:
> Hello
>
>> I would suggest trying either of the following:
>>
>> <parameter>
>> <name>autoReconnect</name>
>> <value>true</value>
>> </parameter>
>>
>
> I know that the above does not work... I tried it.
>
>> or
>>
>> <parameter>
>> <name>url</name>
>>
>> <value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
>> </parameter>
>>
>
> I didn't try this, because I think that the ? in the url is already
> being provided by the code somewhere, so to add it here would duplicate it.
>
>> From what I could tell by reading the code, there is some way to
>> trigger an
>
> expire mechanism at regular intervals - I just don't know how to set
> that up...
>
> Thanks,
> Paul Phillips
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: sweeping stale connections - Commons DBCP and Tomcat 4.1.9
Posted by Paul Phillips <pa...@partitura.com>.
Hello
> I would suggest trying either of the following:
>
> <parameter>
> <name>autoReconnect</name>
> <value>true</value>
> </parameter>
>
I know that the above does not work... I tried it.
> or
>
> <parameter>
> <name>url</name>
>
> <value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
> </parameter>
>
I didn't try this, because I think that the ? in the url is already being
provided by the code somewhere, so to add it here would duplicate it.
>>From what I could tell by reading the code, there is some way to trigger an
expire mechanism at regular intervals - I just don't know how to set that
up...
Thanks,
Paul Phillips
my original message is below...
>
> I'm using Tomcat 4.1.9. I have been having a problem with the DBCP jdbc
> connection pool when used with MySQL. Apparently MySQL kills off stale
> connections after an 8 hour period. According to Mark Matthews (developer
> of the jdbc-mysql driver), I need to configure the pool to sweep out the
> stale connections, and initiate new ones.
>
> I have looked and looked in vain for documentation for DBCP that would
> explain how to set the configuration in my Tomcat server.xml file (using
> JNDI) that would enable this. I can't find anything. I've tried
> examining the source of DBCP, but I'm afraid that I can't figure it out.
>
> My Tomcat server.xml file uses this configuration below, which is right
> out of:
> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-
> ho wto.html
>
>> From what I can tell, there are other parameters that I can enter to
>> force
> the sweeping of stale connections. However, I don't know what they are,
> or how to use them. If anyone can give me an example of the correct
> syntax here, I would be very grateful, ( since my webapp dies every
> night, due to this problem!)
>
> Thanks --
>
> Paul Phillips
>
> (excerpt of server.xml...)
>
> <Context path="/DBTest" docBase="DBTest"
> debug="5" reloadable="true" crossContext="true">
>
> <Logger className="org.apache.catalina.logger.FileLogger"
> prefix="localhost_DBTest_log." suffix=".txt"
> timestamp="true"/>
>
> <Resource name="jdbc/TestDB"
> auth="Container"
> type="javax.sql.DataSource"/>
>
> <ResourceParams name="jdbc/TestDB">
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
> <parameter>
> <name>maxActive</name>
> <value>100</value>
> </parameter>
> <parameter>
> <name>maxIdle</name>
> <value>30000</value>
> </parameter>
> <parameter>
> <name>maxWait</name>
> <value>100</value>
> </parameter>
> <parameter>
> <name>username</name>
> <value>javauser</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value>javadude</value>
> </parameter>
>
> <parameter>
> <name>driverClassName</name>
> <value>org.gjt.mm.mysql.Driver</value>
> </parameter>
>
> <parameter>
> <name>url</name>
> <value>jdbc:mysql://localhost:3306/javatest</value>
> </parameter>
> </ResourceParams>
> </Context>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org> For additional
> commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: sweeping stale connections - Commons DBCP and Tomcat 4.1.9
Posted by Jay Gardner <gj...@qwest.net>.
Hi Paul,
I don't have experience with this pool, but I have experienced this
disconnection problem with mysql. Got around it using the mysql parameter
autoReconnect=true. I would suggest trying either of the following:
<parameter>
<name>autoReconnect</name>
<value>true</value>
</parameter>
or
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
</parameter>
If one is successful, please report back so that we know if it worked for
you or not.
Regards,
--Jay Gardner
-----Original Message-----
From: Paul Phillips [mailto:paul@partitura.com]
Sent: Monday, August 26, 2002 10:04 PM
To: Tomcat Users List
Subject: sweeping stale connections - Commons DBCP and Tomcat 4.1.9
I'm using Tomcat 4.1.9. I have been having a problem with the DBCP jdbc
connection pool when used with MySQL. Apparently MySQL kills off stale
connections after an 8 hour period. According to Mark Matthews (developer
of the jdbc-mysql driver), I need to configure the pool to sweep out the
stale connections, and initiate new ones.
I have looked and looked in vain for documentation for DBCP that would
explain how to set the configuration in my Tomcat server.xml file (using
JNDI) that would enable this. I can't find anything. I've tried examining
the source of DBCP, but I'm afraid that I can't figure it out.
My Tomcat server.xml file uses this configuration below, which is right out
of:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-ho
wto.html
>>From what I can tell, there are other parameters that I can enter to force
the sweeping of stale connections. However, I don't know what they are, or
how to use them. If anyone can give me an example of the correct syntax
here, I would be very grateful, ( since my webapp dies every night, due to
this problem!)
Thanks --
Paul Phillips
(excerpt of server.xml...)
<Context path="/DBTest" docBase="DBTest"
debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30000</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>100</value>
</parameter>
<parameter>
<name>username</name>
<value>javauser</value>
</parameter>
<parameter>
<name>password</name>
<value>javadude</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest</value>
</parameter>
</ResourceParams>
</Context>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: sweeping stale connections - Commons DBCP and Tomcat 4.1.9
Posted by Mike Jackson <mj...@cdi-hq.com>.
Switch to poolman, I've never had this with it. And I've used it
with Informix, Oracle, Postgres, Mysql and DB2.
--mikej
-=-----
mike jackson
mjackson@cdi-hq.com
> -----Original Message-----
> From: Paul Phillips [mailto:paul@partitura.com]
> Sent: Monday, August 26, 2002 9:04 PM
> To: Tomcat Users List
> Subject: sweeping stale connections - Commons DBCP and Tomcat 4.1.9
>
>
> I'm using Tomcat 4.1.9. I have been having a problem with the DBCP jdbc
> connection pool when used with MySQL. Apparently MySQL kills off stale
> connections after an 8 hour period. According to Mark Matthews
> (developer
> of the jdbc-mysql driver), I need to configure the pool to sweep out the
> stale connections, and initiate new ones.
>
> I have looked and looked in vain for documentation for DBCP that would
> explain how to set the configuration in my Tomcat server.xml file (using
> JNDI) that would enable this. I can't find anything. I've tried
> examining
> the source of DBCP, but I'm afraid that I can't figure it out.
>
> My Tomcat server.xml file uses this configuration below, which is
> right out
> of:
> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-ex
> amples-ho
> wto.html
>
> >From what I can tell, there are other parameters that I can
> enter to force
> the sweeping of stale connections. However, I don't know what
> they are, or
> how to use them. If anyone can give me an example of the correct syntax
> here, I would be very grateful, ( since my webapp dies every
> night, due to
> this problem!)
>
> Thanks --
>
> Paul Phillips
>
> (excerpt of server.xml...)
>
> <Context path="/DBTest" docBase="DBTest"
> debug="5" reloadable="true" crossContext="true">
>
> <Logger className="org.apache.catalina.logger.FileLogger"
> prefix="localhost_DBTest_log." suffix=".txt"
> timestamp="true"/>
>
> <Resource name="jdbc/TestDB"
> auth="Container"
> type="javax.sql.DataSource"/>
>
> <ResourceParams name="jdbc/TestDB">
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
> <parameter>
> <name>maxActive</name>
> <value>100</value>
> </parameter>
> <parameter>
> <name>maxIdle</name>
> <value>30000</value>
> </parameter>
> <parameter>
> <name>maxWait</name>
> <value>100</value>
> </parameter>
> <parameter>
> <name>username</name>
> <value>javauser</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value>javadude</value>
> </parameter>
>
> <parameter>
> <name>driverClassName</name>
> <value>org.gjt.mm.mysql.Driver</value>
> </parameter>
>
> <parameter>
> <name>url</name>
> <value>jdbc:mysql://localhost:3306/javatest</value>
> </parameter>
> </ResourceParams>
> </Context>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>