Re: org.postgresql.util.PSQLException: An I/O error has occured while flushing the output

From: Jonathan Fuerth <fuerth(at)sqlpower(dot)ca>
To: Kishore Kolli <kkolli(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: org.postgresql.util.PSQLException: An I/O error has occured while flushing the output
Date: 2005-12-09 20:09:08
Message-ID: 385133ace3c5280b1b2df75125cd520a@sqlpower.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Dec 8, 2005, at 4:58 PM, Kishore Kolli wrote:

>  The application dumps the following error in the following cases:
>    1. The postgres process is restarted.
>    2. The network connection between the machine running postgres and
> tomcat has been reset.
> [...] 
> Any idea how to make tomcat reconnect to the database with out any
> problems ?
>  

It's not a Postgres specific answer, but here's an answer nonetheless:

It appears from the stack trace that you are using the Jakarta Commons
DBCP package. If you set a validationQuery on your connection pool,
the pool manager will automatically test your database connections
before giving them to Hibernate. If you have had a network outage or
server restart, the pooled connections will fail that test, and the
DBCP will dump those broken connections and open new ones before
returning them to Hibernate.

For your validation, pick a simple query that is guaranteed to return
at least one row, but will not be expensive to execute (because it will
be executed frequently!). For example, you could use "SELECT now()",
which doesn't even require disk access.

See http://jakarta.apache.org/commons/dbcp/configuration.html for
details on DBCP configuration.

-Jonathan

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Russell Francis 2005-12-10 17:25:47 PGinet, PGcidr & PGmacaddr contributions
Previous Message Michael Paesold 2005-12-09 09:43:52 Re: Problem with 8.1 driver