pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marc Herbert <Marc.Herbert@continuent.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Catching postgres exceptions - functions returning error values?
Date: Wed, 30 Aug 2006 18:27:40 +0200
Message-ID: <khjlkp6yyrn.fsf@meije.emic.fr> (raw)
References: <1156948727.29660.24.camel@localhost.localdomain>

Mario Splivalo <mario.splivalo@mobart.hr> writes:

> Now, if the database server is unavailable, I get something like this:
>
> org.postgresql.util.PSQLException: Connection refused. Check that the
> hostname and port are correct and that the postmaster is accepting
> TCP/IP connections.
>
> I would like to know, in my code, what happened, and inform user
> apropriatley, I don't want just to print the exception to the user.

What would like to substitute to the above message for instance? Is
this just a language issue?


> I could parse the return from printStackTrace method, but that just
> doesn't seem right.
>
> Also, some of the functions need to return errorcode of some sort. If
> the function is returning SETOF, I can't use OUT parametars. So, I'm
> asking for a recomendation here.

Maybe you want to use the SQLState

http://www.postgresql.org/docs/8.1/interactive/errcodes-appendix.html

http://www.easysoft.com/developer/interfaces/odbc/sqlstate_status_return_codes.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcodbc_error_codes.asp

http://www.opengroup.org/bookstore/catalog/c451.htm (appendix A)
http://www.opengroup.org/bookstore/catalog/c449.htm (appendix B)






view thread (3+ messages)  latest in thread

Message-ID: <khjlkp6yyrn.fsf@meije.emic.fr>
Permalink:  ../khjlkp6yyrn.fsf@meije.emic.fr/
Also on:    postgresql.org/message-id/khjlkp6yyrn.fsf@meije.emic.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: Marc.Herbert@continuent.com
  Subject: Re: Catching postgres exceptions - functions returning error values?
  In-Reply-To: <khjlkp6yyrn.fsf@meije.emic.fr>
  References: <1156948727.29660.24.camel@localhost.localdomain> <khjlkp6yyrn.fsf@meije.emic.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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