Re: res.getInt() returns 0 for NULL?

From: Kris Jurka <books(at)ejurka(dot)com>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: res.getInt() returns 0 for NULL?
Date: 2002-11-07 06:35:01
Message-ID: Pine.LNX.4.33.0211070134280.30478-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


This is according to the JDBC spec. Check the API docs for getInt()

On Thu, 7 Nov 2002, Jean-Christian Imbeault wrote:

> Just need a clarification. When using res.getInt() on a column with a
> null value I am getting back "0", should I not get some error thrown or
> some kind or error instead?
>
> The following code illustrates:
>
> int id = res.getInt("id");
> if (res.wasNull()) {
> System.out.println("result was null");
> }
> System.out.println("id is " + id);
>
> Output:
>
> result was null
> id is 0
>
>
> Thanks,
>
> Jc
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message lxj 2002-11-07 11:40:24 Hi!
Previous Message Jean-Christian Imbeault 2002-11-07 05:53:25 res.getInt() returns 0 for NULL?