Re: SQLException and error code

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <Peter(dot)Zoche(at)materna(dot)de>, <oliver(at)opencloud(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: SQLException and error code
Date: 2005-07-28 15:13:21
Message-ID: s2e8afd3.056@gwmta.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

To better support existing applications which (for reasons I don't
really understand) rely on the vendor-specific errorCode instead of the
ANSI-standard sqlState, you could implement getErrorCode as:

return Integer.parseInt(getSqlState(), 36);

-Kevin


>>> Oliver Jowett <oliver(at)opencloud(dot)com> 07/26/05 6:33 PM >>>
Peter(dot)Zoche(at)materna(dot)de wrote:
> Because in the postgresql documentation you can find the following
page:
>
>
http://www.postgresql.org/docs/8.0/interactive/errcodes-appendix.html#ERRCOD
> ES-TABLE
>
> There you can see all ERROR CODES!

Those codes are actually SQLSTATEs.

> So why is there a method getErrorCode(),

It's defined by the JDBC spec, we don't have any choice about whether it
is there or not.

> if the only thing it does
> is to return zero?

Back to my original question: what are you expecting it to return? It
can't return a SQLSTATE because it returns an int and SQLSTATE is
alphanumeric. We don't have any other useful error code. So we just
return 0 because we have to return *something*.

-O

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2005-07-28 15:15:11 Re: Proposed patch for showing originating query on error
Previous Message Oliver Jowett 2005-07-28 15:06:48 Re: Proposed patch for showing originating query on error