File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes how to do a null check for a big int value in database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to do a null check for a big int value in database." Watch "how to do a null check for a big int value in database." New topic
Author

how to do a null check for a big int value in database.

Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

hey guys,

Problem: I got a field which is a BIGINT in the database (DB2), which is nullable and defaults to NULL,

when I get the resultset in my code how do I check for a null in the code. I am mapping the field to a long variable
i.e - when I do a rs.getLong how do I check for null before setting the value into some variable.

Thanks in advance.
Regards.


Time is what we want the most, but what we use the worst. -- William Penn
Aurelian Tutuianu
Ranch Hand

Joined: May 13, 2004
Posts: 86
I see two ways to solve that.
First is to call rs.getObject, this should return null value in case of sql null.
Second and better solution is calling rs.wasNull immediately after rs.getLong. You find about null value after, not before, but is a better solution.


http://javasign.blogspot.com/
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

thanks.. problem solved... : )
 
Consider Paul's rocket mass heater.
 
subject: how to do a null check for a big int value in database.