This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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... : )
 
 
subject: how to do a null check for a big int value in database.
 
Similar Threads
How to have checkbox value blank instead of "null"
Parsing
How javascript variable assigned to JSP variable
Problem with null field
In SQL, what kind of value is NULL? How can I check if a field is NULL?