Re: Extracting more useful information from PSQLException - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Extracting more useful information from PSQLException
Date
Msg-id alpine.BSO.2.00.1301311951020.23428@leary.csoft.net
Whole thread Raw
In response to Re: Extracting more useful information from PSQLException  (Kris Jurka <books@ejurka.com>)
Responses Re: Extracting more useful information from PSQLException  (Steven Schlansker <stevenschlansker@gmail.com>)
List pgsql-jdbc

On Fri, 28 Dec 2012, Kris Jurka wrote:

> On Fri, 28 Dec 2012, Steven Schlansker wrote:
>
> > Is it possible / would it be a good addition to expose structured SQL
> > error information through JDBC?  If such a thing does not exist, is this
> > a feasible contribution?  I expect it might require some hacking on the
> > PostgreSQL server side to expose the error information in a structured
> > manner.  Or am I just dreaming too much, and this is not feasible?
> >
>
> There is currently a patch in progress and under discussion for the server
> changes to expose this information.

This patch was committed to the server and I've exposed these field in the
JDBC driver through the somewhat ugly...

} catch (SQLException sqle) {
    ServerErrorMessage err =
((PSQLException)sqle).getServerErrorMessage();
    System.out.println(err.getTable());
}

The server infrastructure doesn't cover all the error cases I would have
hoped, so you can't just through data at the database and always be able
to produce an intelligent error response to a user, but it's a start.

http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=991f3e5ab3f8196d18d5b313c81a5f744f3baaea

https://github.com/pgjdbc/pgjdbc/commit/e9ac5f8d964202ab5d43e401d74dcd76cefd112e


Kris Jurka


pgsql-jdbc by date:

Previous
From: dmp
Date:
Subject: Re: JDBC connection test with SSL on PG 9.2.1 server
Next
From: News Subsystem
Date:
Subject: ...