pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mario Splivalo <mario.splivalo@mobart.hr>
To: pgsql-jdbc@postgresql.org
Subject: Re: Catching postgres exceptions - functions returning
Date: Thu, 31 Aug 2006 11:22:39 +0200
Message-ID: <1157016159.3326.8.camel@localhost.localdomain> (raw)
In-Reply-To: <khjlkp6yyrn.fsf@meije.emic.fr>
References: <1156948727.29660.24.camel@localhost.localdomain>
	<khjlkp6yyrn.fsf@meije.emic.fr>

On Wed, 2006-08-30 at 18:27 +0200, Marc Herbert wrote:
> > 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)
> 

Thank you! :) Although I've found out that errcodes-appendix.html from
postgresql manual doesn't contain some errors, for instance:

org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.
        at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:204)
        at org.postgresql.Driver.connect(Driver.java:139)
        at java.sql.DriverManager.getConnection(DriverManager.java:525)
        at java.sql.DriverManager.getConnection(DriverManager.java:171)
        at Example1.main(Example1.java:31)
--------------------------
Message:   Connection refused. Check that the hostname and port are
correct and that the postmaster is accepting TCP/IP connections.
SQLState:  08004
ErrorCode: 0

This, 08004 is not listed there.

Then, if I throw some 'custom' exception from postgres (using plpgsql
RAISE EXCEPTION), I'll get SQLState code P0001 from getSQLState(). If I
want to know what realy happened, I need to parse what getMessage()
returns. Is there another way?

	Mario
-- 
Mario Splivalo
Mob-Art
mario.splivalo@mobart.hr

"I can do it quick, I can do it cheap, I can do it well. Pick any two."





view thread (3+ messages)

Message-ID: <1157016159.3326.8.camel@localhost.localdomain>
Permalink:  ../1157016159.3326.8.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1157016159.3326.8.camel@localhost.localdomain

 · 

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: mario.splivalo@mobart.hr
  Subject: Re: Catching postgres exceptions - functions returning
  In-Reply-To: <1157016159.3326.8.camel@localhost.localdomain>
  References: <1156948727.29660.24.camel@localhost.localdomain> <khjlkp6yyrn.fsf@meije.emic.fr> <1157016159.3326.8.camel@localhost.localdomain>

* 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