Re: org.postgresql.util.PSQLException: An I/O error has occured while flushing the output - Mailing list pgsql-jdbc

From Jonathan Fuerth
Subject Re: org.postgresql.util.PSQLException: An I/O error has occured while flushing the output
Date
Msg-id 385133ace3c5280b1b2df75125cd520a@sqlpower.ca
Whole thread Raw
In response to org.postgresql.util.PSQLException: An I/O error has occured while flushing the output  (Kishore Kolli <kkolli@gmail.com>)
Responses Re: org.postgresql.util.PSQLException: An I/O error has occured while flushing the output
List pgsql-jdbc
On Dec 8, 2005, at 4:58 PM, Kishore Kolli wrote:


<excerpt><fontfamily><param>Arial</param><smaller> The application
dumps the following error in the following cases:</smaller></fontfamily>

<fontfamily><param>Arial</param><smaller>   1. The postgres process is
restarted.</smaller></fontfamily>

<fontfamily><param>Arial</param><smaller>   2. The network connection
between the machine running postgres and tomcat has been reset.</smaller></fontfamily>

[...] 

<fontfamily><param>Arial</param><smaller>Any idea how to make tomcat
reconnect to the database with out any problems ?</smaller></fontfamily>

 

</excerpt>

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.


-JonathanOn 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

pgsql-jdbc by date:

Previous
From: Michael Paesold
Date:
Subject: Re: Problem with 8.1 driver
Next
From: Russell Francis
Date:
Subject: PGinet, PGcidr & PGmacaddr contributions