pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to retry when connection has been closed?
2+ messages / 2 participants
[nested] [flat]

* How to retry when connection has been closed?
@ 2009-08-02 09:12 Herouth Maoz <herouth@unicell.co.il>
  2009-08-02 22:20 ` Re: How to retry when connection has been closed? Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Herouth Maoz @ 2009-08-02 09:12 UTC (permalink / raw)
  To: 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,
Herouth



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How to retry when connection has been closed?
  2009-08-02 09:12 How to retry when connection has been closed? Herouth Maoz <herouth@unicell.co.il>
@ 2009-08-02 22:20 ` Oliver Jowett <oliver@opencloud.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Oliver Jowett @ 2009-08-02 22:20 UTC (permalink / raw)
  To: Herouth Maoz <herouth@unicell.co.il>; +Cc: pgsql-jdbc

Herouth Maoz wrote:

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

Test the SQLState of the thrown SQLException. See
http://www.postgresql.org/docs/8.4/static/errcodes-appendix.html

-O



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2009-08-02 22:20 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-08-02 09:12 How to retry when connection has been closed? Herouth Maoz <herouth@unicell.co.il>
2009-08-02 22:20 ` Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox