Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Aurelian Tutuianu
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.. problem solved... : )
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic