res.getInt() returns 0 for NULL? - Mailing list pgsql-jdbc

From Jean-Christian Imbeault
Subject res.getInt() returns 0 for NULL?
Date
Msg-id 3DC9FFD5.7080408@mega-bucks.co.jp
Whole thread Raw
Responses Re: res.getInt() returns 0 for NULL?
List 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


pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: setBoolean()
Next
From: Kris Jurka
Date:
Subject: Re: res.getInt() returns 0 for NULL?