Re: Please help! - Constraints Exception

From: Dennis Brakhane <brakhane(at)googlemail(dot)com>
To: Ivan Bojer <ibojer(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Please help! - Constraints Exception
Date: 2009-06-17 20:04:01
Message-ID: 226a19190906171304n2b306a0ufc676ad7be76b0e1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Wed, Jun 17, 2009 at 9:57 PM, Ivan Bojer<ibojer(at)gmail(dot)com> wrote:
> I have a table with UNIQUE constraint on the column. Inserting 2 of
> same values on it fails (as it should)
> and I can see DBLog Error message. Alas, there is no exception thrown
> from JDBC so that I can properly
> handle it.

This is from memory, so if I talk nonsense, I hope somebody corrects me.

The exception thrown should be a SQLException. These have a
"getSQLState" method which returns a string. If this string is
"23505", you have a UNIQUE violation.

You can see the possible error codes here:

http://www.postgresql.org/docs/8.3/static/errcodes-appendix.html

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dennis Brakhane 2009-06-17 20:05:36 Re: Please help! - Constraints Exception
Previous Message Ivan Bojer 2009-06-17 19:57:54 Please help! - Constraints Exception