Re: Meaningful Exception handling

From: Barry Lind <barry(at)xythos(dot)com>
To: AgentM <agentm(at)cmu(dot)edu>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Meaningful Exception handling
Date: 2002-04-17 05:23:14
Message-ID: 3CBD06C2.6030109@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

First off you do know that you can't catch an error in postgres and
continue on, don't you? Any error in postgres aborts the current
transaction. Thus after an error you must rollback and start a new
transaction, and then you need to redo all the work up to the point of
the error. This isn't generally something you can easily do when
catching an exception.

Answering your specific question: comparing the string error message is
currently the only way to determine the error. There is a TODO item for
the database to support error codes, and when the database adds that
support the jdbc driver will as well.

thanks,
--Barry

AgentM wrote:
> First off, thanks for the quick help with my previous simple problem.
>
> Now I'd like to catch SQLExceptions selectively. For example, I have a
> uniquely indexed column in Table A. I would like to insert into this
> column and I don't care if the insert fails due to duplication. But I
> would want to know if something else went wrong. Is there a way to
> specifically catch and ignore this particular instance of the
> SQLException short of comparing a String to the database's returned
> error message? Are there any docs referring to SQLException messages
> thrown? Thanks again.

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Barry Lind 2002-04-17 05:25:55 Re: Fixes for JDBC's getColumns() in Postgresql 7.2 &
Previous Message Stuart Robinson 2002-04-17 04:42:02 callable statements