File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes getInt() on a NULL value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "getInt() on a NULL value" Watch "getInt() on a NULL value" New topic

getInt() on a NULL value

Peter Straw
Ranch Hand

Joined: Jan 08, 2002
Posts: 79
I am using this code;
int myInt = myResultSet.getInt("myValue")
The problem is that I need to know if myValue is NULL in the database or if it is actually 0.
How is this done please?
Many thanks...
Snigdha Solanki
Ranch Hand

Joined: Sep 07, 2000
Posts: 128
You can use wasNull() method to check if the last column read had a value of SQL NULL. Before that call getInt() to read the value.

Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform
I agree. Here's the link:
subject: getInt() on a NULL value
It's not a secret anymore!