You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lutischán Ferenc <lu...@gmail.com> on 2013/05/08 14:54:50 UTC

Tomcat JDBC with PostgreSQL

Dear Users,

Tomcat 7.0.39.

I have the following configuration in META-INF/context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context cookies="false" path="/xxxx" reloadable="true">
     <Resource name="jdbc/template" auth="Container" 
driverClassName="org.postgresql.Driver" 
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" initialSize="2" 
maxIdle="20" maxActive="20" maxWait="5000" password="xxxx" 
type="javax.sql.DataSource" url="jdbc:postgresql://x.x.x.x/x" 
username="template" validationQuery="select 1" 
jdbcInterceptors="ConnectionState;SlowQueryReportJmx(threshold=1000)"/>
</Context>

The situation:
- The database side the connection closed
- The tomcat pool don't renew the connection

How to fix it?

Regards,
          Ferenc

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


Re: Tomcat JDBC with PostgreSQL

Posted by Lutischán Ferenc <lu...@gmail.com>.
Thanks Dan,
I would like to test it more, but I think it works.

2013.05.08. 15:01 keltezéssel, Daniel Mikusa írta:
> On May 8, 2013, at 8:54 AM, Lutischán Ferenc wrote:
>
>> Dear Users,
>>
>> Tomcat 7.0.39.
>>
>> I have the following configuration in META-INF/context.xml:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <Context cookies="false" path="/xxxx" reloadable="true">
>>     <Resource name="jdbc/template" auth="Container" driverClassName="org.postgresql.Driver" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" initialSize="2" maxIdle="20" maxActive="20" maxWait="5000" password="xxxx" type="javax.sql.DataSource" url="jdbc:postgresql://x.x.x.x/x" username="template" validationQuery="select 1" jdbcInterceptors="ConnectionState;SlowQueryReportJmx(threshold=1000)"/>
>> </Context>
>>
>> The situation:
>> - The database side the connection closed
>> - The tomcat pool don't renew the connection
> Try setting testOnBorrow to "true".  With the Tomcat JDBC connection pool the testOn* properties default to false, which is different than the defaults for DBCP.
>
> Dan
>
>> How to fix it?
>>
>> Regards,
>>          Ferenc
>>
>> ---------------------------------------------------------------------
>> 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: Tomcat JDBC with PostgreSQL

Posted by Daniel Mikusa <dm...@gopivotal.com>.
On May 8, 2013, at 8:54 AM, Lutischán Ferenc wrote:

> Dear Users,
> 
> Tomcat 7.0.39.
> 
> I have the following configuration in META-INF/context.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <Context cookies="false" path="/xxxx" reloadable="true">
>    <Resource name="jdbc/template" auth="Container" driverClassName="org.postgresql.Driver" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" initialSize="2" maxIdle="20" maxActive="20" maxWait="5000" password="xxxx" type="javax.sql.DataSource" url="jdbc:postgresql://x.x.x.x/x" username="template" validationQuery="select 1" jdbcInterceptors="ConnectionState;SlowQueryReportJmx(threshold=1000)"/>
> </Context>
> 
> The situation:
> - The database side the connection closed
> - The tomcat pool don't renew the connection

Try setting testOnBorrow to "true".  With the Tomcat JDBC connection pool the testOn* properties default to false, which is different than the defaults for DBCP.

Dan

> 
> How to fix it?
> 
> Regards,
>         Ferenc
> 
> ---------------------------------------------------------------------
> 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