Skip site navigation (1) Skip section navigation (2)

How to retry when connection has been closed?

From: Herouth Maoz <herouth(at)unicell(dot)co(dot)il>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: How to retry when connection has been closed?
Date: 2009-08-02 09:12:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Good day.

We are upgrading a legacy system from Sybase to Postgres. In one of the 
modules, we wish, if an SQLException is caught, to close and reopen the 
connection and retry - but only if the cause of the Exception is a dropped 
connection. The original developer of the code implemented this by searching 
for the substrings "Broken pipe" or "Connection already closed" in the 
exception message.

Is there a more elegant way to find out whether the connection has been 
dropped from within the catch clause?

And if not, I assume the above substrings are no longer pertinent - what 
messages in PostgreSQL indicate a dropped connection?

Thank you,


pgsql-jdbc by date

Next:From: Oliver JowettDate: 2009-08-02 22:20:47
Subject: Re: How to retry when connection has been closed?
Previous:From: Thomas KellererDate: 2009-08-01 20:53:59
Subject: Datatype of domains not reported correctly.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group