pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
SQLException.getErrorCode ?
7+ messages / 4 participants
[nested] [flat]

* SQLException.getErrorCode ?
@ 2010-05-01 16:11  Maxime Lévesque <maxime.levesque@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Maxime Lévesque @ 2010-05-01 16:11 UTC (permalink / raw)
  To: pgsql-jdbc

 The method  SQLException.getErrorCode of the jdbc driver systematically
returns 0,

 From what I have found on the web, the server doesn't have good support for
error codes,
and it is the reason the jdbc driver doesn't return error codes.

The doc here talks about error codes :

 http://www.postgresql.org/docs/8.4/interactive/errcodes-appendix.html

Where are error codes support on the roadmap ?

I would like to detect things like 'table does not exist' , constraint does
not exist, etc.. from the SQLException

 Is there a workaround ?

 Thanks

 And thanks for the quick replies to my previous questions ! ;-)

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

* Re: SQLException.getErrorCode ?
@ 2010-05-01 16:20  Kris Jurka <books@ejurka.com>
  parent: Maxime Lévesque <maxime.levesque@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Kris Jurka @ 2010-05-01 16:20 UTC (permalink / raw)
  To: Maxime Lévesque <maxime.levesque@gmail.com>; +Cc: pgsql-jdbc



On Sat, 1 May 2010, Maxime L?vesque wrote:

>  The method  SQLException.getErrorCode of the jdbc driver systematically
> returns 0,
> 
>  http://www.postgresql.org/docs/8.4/interactive/errcodes-appendix.html

As I said earlier you need to check SQLException.getSQLState, not 
getErrorCode.  As you can see the error conditions listed in the appendix 
are not all numeric so they cannot be returned via getErrorCode.

Kris Jurka


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

* Re: SQLException.getErrorCode ?
@ 2010-05-01 18:25  Kevin Grittner <Kevin.Grittner@wicourts.gov>
  parent: Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Kevin Grittner @ 2010-05-01 18:25 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; maxime.levesque@gmail.com; +Cc: pgsql-jdbc

Kris Jurka <books@ejurka.com> wrote:
 
> As I said earlier you need to check SQLException.getSQLState, not 
> getErrorCode.
 
Why anyone would want to use error code instead of SQLSTATE is
beyond me, but since they're out there, perhaps we should implement
getErrorCode to interpret SQLSTATE as a base 36 number, and return
that number?  It might take less time than fielding the next
complaint.  ;-)
 
If that sounds good, I could whip together a patch for it.
 
The biggest down side is that we'd have to document it....
 
-Kevin



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

* Re: SQLException.getErrorCode ?
@ 2010-05-01 19:44  Kris Jurka <books@ejurka.com>
  parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
  0 siblings, 1 reply; 7+ messages in thread

From: Kris Jurka @ 2010-05-01 19:44 UTC (permalink / raw)
  To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: maxime.levesque@gmail.com; pgsql-jdbc



On Sat, 1 May 2010, Kevin Grittner wrote:

> Kris Jurka <books@ejurka.com> wrote:
>
>> As I said earlier you need to check SQLException.getSQLState, not
>> getErrorCode.
>
> Why anyone would want to use error code instead of SQLSTATE is
> beyond me, but since they're out there, perhaps we should implement
> getErrorCode to interpret SQLSTATE as a base 36 number, and return
> that number?  It might take less time than fielding the next
> complaint.  ;-)
>
> The biggest down side is that we'd have to document it....
>

Exactly, who's going to maintain this list of alternate error code 
versions?  If the main project was to put this version of the error codes 
in the master table of error codes, then I guess it would be OK.  I can't 
imagine proposing that though, unless there are other driver projects that 
are in the same position.

Kris Jurka



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

* Re: SQLException.getErrorCode ?
@ 2010-05-01 21:41  Maxime Lévesque <maxime.levesque@gmail.com>
  parent: Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Maxime Lévesque @ 2010-05-01 21:41 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; pgsql-jdbc

 The getSQLState method is perfectly fine with me, I was mislead when I
found
old posts on the web that said  that error codes were not supported at the
server level.
I had first tried using the getErrorCode because all other drivers I have
used
use this method. I guess making the getSQLState documentation easy available

would be the first thing to do.

 Cheers


On Sat, May 1, 2010 at 3:44 PM, Kris Jurka <books@ejurka.com> wrote:

>
>
> On Sat, 1 May 2010, Kevin Grittner wrote:
>
>  Kris Jurka <books@ejurka.com> wrote:
>>
>>  As I said earlier you need to check SQLException.getSQLState, not
>>> getErrorCode.
>>>
>>
>> Why anyone would want to use error code instead of SQLSTATE is
>> beyond me, but since they're out there, perhaps we should implement
>> getErrorCode to interpret SQLSTATE as a base 36 number, and return
>> that number?  It might take less time than fielding the next
>> complaint.  ;-)
>>
>> The biggest down side is that we'd have to document it....
>>
>>
> Exactly, who's going to maintain this list of alternate error code
> versions?  If the main project was to put this version of the error codes in
> the master table of error codes, then I guess it would be OK.  I can't
> imagine proposing that though, unless there are other driver projects that
> are in the same position.
>
> Kris Jurka
>

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

* Re: SQLException.getErrorCode ?
@ 2010-05-02 00:17  Maxime Lévesque <maxime.levesque@gmail.com>
  parent: Maxime Lévesque <maxime.levesque@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Maxime Lévesque @ 2010-05-02 00:17 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>; pgsql-jdbc

 I was just thinking that putting the getSQLState string in the exception's
toString
message would go a long way in hinting the users that postgres does provide
error codes.

 Anyways thanks for all the answers ;-)


2010/5/1 Maxime Lévesque <maxime.levesque@gmail.com>

>
>  The getSQLState method is perfectly fine with me, I was mislead when I
> found
> old posts on the web that said  that error codes were not supported at the
> server level.
> I had first tried using the getErrorCode because all other drivers I have
> used
> use this method. I guess making the getSQLState documentation easy
> available
> would be the first thing to do.
>
>  Cheers
>
>
>
> On Sat, May 1, 2010 at 3:44 PM, Kris Jurka <books@ejurka.com> wrote:
>
>>
>>
>> On Sat, 1 May 2010, Kevin Grittner wrote:
>>
>>  Kris Jurka <books@ejurka.com> wrote:
>>>
>>>  As I said earlier you need to check SQLException.getSQLState, not
>>>> getErrorCode.
>>>>
>>>
>>> Why anyone would want to use error code instead of SQLSTATE is
>>> beyond me, but since they're out there, perhaps we should implement
>>> getErrorCode to interpret SQLSTATE as a base 36 number, and return
>>> that number?  It might take less time than fielding the next
>>> complaint.  ;-)
>>>
>>> The biggest down side is that we'd have to document it....
>>>
>>>
>> Exactly, who's going to maintain this list of alternate error code
>> versions?  If the main project was to put this version of the error codes in
>> the master table of error codes, then I guess it would be OK.  I can't
>> imagine proposing that though, unless there are other driver projects that
>> are in the same position.
>>
>> Kris Jurka
>>
>
>

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

* Re: SQLException.getErrorCode ?
@ 2010-05-03 04:26  Lew <noone@lwsc.ehost-services.com>
  parent: Maxime Lévesque <maxime.levesque@gmail.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Lew @ 2010-05-03 04:26 UTC (permalink / raw)
  To: pgsql-jdbc

On 05/01/2010 08:17 PM, Maxime Lévesque wrote:
>
>   I was just thinking that putting the getSQLState string in the
> exception's toString
> message would go a long way in hinting the users that postgres [sic] does
> provide error codes.

Umm, the SQLException documentation is quite clear the 'getErrorCode()' 
returns only vendor-specific codes and that 'getSQLState()' returns the SQL 
state value.  Since the latter is standard and the former is not, that already 
"goes a long way [to] hinting ... that" PG provides SQL Standard codes. 
Nothing further is needed.
<http://java.sun.com/javase/6/docs/api/java/sql/SQLException.html;

It seems fair that there is a presumption of knowledge of the standard.

-- 
Lew



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


end of thread, other threads:[~2010-05-03 04:26 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-05-01 16:11 SQLException.getErrorCode ? Maxime Lévesque <maxime.levesque@gmail.com>
2010-05-01 16:20 ` Kris Jurka <books@ejurka.com>
2010-05-01 18:25   ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2010-05-01 19:44     ` Kris Jurka <books@ejurka.com>
2010-05-01 21:41       ` Maxime Lévesque <maxime.levesque@gmail.com>
2010-05-02 00:17         ` Maxime Lévesque <maxime.levesque@gmail.com>
2010-05-03 04:26           ` Lew <noone@lwsc.ehost-services.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