res.getInt() returns 0 for NULL?

From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: res.getInt() returns 0 for NULL?
Date: 2002-11-07 05:53:25
Message-ID: 3DC9FFD5.7080408@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2002-11-07 06:35:01 Re: res.getInt() returns 0 for NULL?
Previous Message Jonathan T. Higa 2002-11-07 00:57:45 gcj oddity