pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Please help! - Constraints Exception
4+ messages / 2 participants
[nested] [flat]

* Please help! - Constraints Exception
@ 2009-06-17 19:57  Ivan Bojer <ibojer@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Ivan Bojer @ 2009-06-17 19:57 UTC (permalink / raw)
  To: pgsql-jdbc

Hello all,

I am new to pgsql-JDBC and I apologize if this is a trivial question
but I can not hack it!

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.

Any hints are appreciated!

Config
--------
postgresql 8.3
JDBC3 (8.3-604)
database is accessed through the network



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Please help! - Constraints Exception
@ 2009-06-17 20:04  Dennis Brakhane <brakhane@googlemail.com>
  parent: Ivan Bojer <ibojer@gmail.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Dennis Brakhane @ 2009-06-17 20:04 UTC (permalink / raw)
  To: Ivan Bojer <ibojer@gmail.com>; +Cc: pgsql-jdbc

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Please help! - Constraints Exception
@ 2009-06-17 20:05  Dennis Brakhane <brakhane@googlemail.com>
  parent: Dennis Brakhane <brakhane@googlemail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Dennis Brakhane @ 2009-06-17 20:05 UTC (permalink / raw)
  To: Ivan Bojer <ibojer@gmail.com>; +Cc: pgsql-jdbc

Sorry, I missed the "no exception thrown" part. How exactly do you
issue the query? Can you give a code example?



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Please help! - Constraints Exception
@ 2009-06-17 20:37  Ivan Bojer <ibojer@gmail.com>
  parent: Dennis Brakhane <brakhane@googlemail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Ivan Bojer @ 2009-06-17 20:37 UTC (permalink / raw)
  To: Dennis Brakhane <brakhane@googlemail.com>; +Cc: pgsql-jdbc

FYI I figured what was the problem. The database log level was changed
to FATAL from ERROR (default?).



On Wed, Jun 17, 2009 at 1:04 PM, Dennis Brakhane<brakhane@googlemail.com> wrote:
> 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
>



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2009-06-17 20:37 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-06-17 19:57 Please help! - Constraints Exception Ivan Bojer <ibojer@gmail.com>
2009-06-17 20:04 ` Dennis Brakhane <brakhane@googlemail.com>
2009-06-17 20:05   ` Dennis Brakhane <brakhane@googlemail.com>
2009-06-17 20:37   ` Ivan Bojer <ibojer@gmail.com>

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