Re: PoolingDataSource: java.sql.SQLException: Connection is closed

From: Sean Owen <srowen(at)gmail(dot)com>
To: dev(at)community(dot)apache(dot)org
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PoolingDataSource: java.sql.SQLException: Connection is closed
Date: 2010-11-18 17:13:32
Message-ID: AANLkTikxEgKEXPEYTc6z9XuZwuQd-i5o8jg6RX+OB__x@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

The pool is not being able to check whether a connection is still usable
before using it.

I've never used PostgreSQL myself, but, for MySQL, I've always specified a
query that can be used to test the connection in a pool to see if it's
alive. You might try:

validationQuery="SELECT 1"

You can try that.

Incidentally I put in an 'experimental' alternative implementation of the
DataSource for PostgreSQL. I'd be interested to know if you are using it and
if it works. It has to do a few things differently than the MySQL version
which uses some MySQL-specific shortcuts as optimizations.

On Thu, Nov 18, 2010 at 5:10 PM, Michael musset <mickamusset(at)gmail(dot)com>wrote:

> Hi,
>
> On my Ubuntu 10.04 Server, I have Tomcat6 running + Postgresql 9.
>
> I use the javax.sql.DataSource like that on my context.xml file :
>
> <Context>
> <Resource name="jdbc/**********"
> auth="Container"
> type="javax.sql.DataSource"
> maxActive="100"
> maxIdle="30"
> maxWait="20000"
> removeAbandoned="true"
> removeAbandonedTimeout="1120"
> username="**********"
> password="******"
> logAbandoned="true"
> driverClassName="org.postgresql.Driver"
> url="jdbc:postgresql://localhost/DB?autoReconnect=true"
> />
> </Context>
>
>
> do you have an idea why I got this error ? :
>
> java.sql.SQLException: Connection is closed.
> at
>
> org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:185)
> at
>
> org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:317)
>
>
> When i'm trying to do get a Preparestatement or sometimes on the execute()
> command.
>
>
> My idea is there is too much connection not closed correctly, but i'm sure
> that i closed every connection that I open.
> And in my context configuration I use :
> removeAbandoned="true"
> removeAbandonedTimeout="1120"
>
> and jdbc:postgresql://localhost/DB?*autoReconnect=true*
>
> Thanks in advance for the help.
>
>
>
>
> --
> Michael Musset,
> Tel: 06 26 06 29 89
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Thomas Markus 2010-11-19 09:55:36 Re: JDBC : this statement has been closed : postgresql 9
Previous Message Michael musset 2010-11-18 17:10:02 PoolingDataSource: java.sql.SQLException: Connection is closed