From: Dennis Brakhane <brakhane@googlemail.com>
To: Ivan Bojer <ibojer@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Please help! - Constraints Exception
Date: Wed, 17 Jun 2009 22:04:01 +0200
Message-ID: <226a19190906171304n2b306a0ufc676ad7be76b0e1@mail.gmail.com> (raw)
In-Reply-To: <ac6251120906171257q69116eees210591ca33eae151@mail.gmail.com>
References: <ac6251120906171257q69116eees210591ca33eae151@mail.gmail.com>
On Wed, Jun 17, 2009 at 9:57 PM, Ivan Bojer<ibojer@gmail.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
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: brakhane@googlemail.com, ibojer@gmail.com
Subject: Re: Please help! - Constraints Exception
In-Reply-To: <226a19190906171304n2b306a0ufc676ad7be76b0e1@mail.gmail.com>
References: <ac6251120906171257q69116eees210591ca33eae151@mail.gmail.com> <226a19190906171304n2b306a0ufc676ad7be76b0e1@mail.gmail.com>
* 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