Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

intVar = ResultSet.getInt(i) => NPE; how to handle?

807598Jul 25 2006 — edited Jul 30 2006
Hello, no code example since this shouldn't be too difficult to explain. I'm calling a storedproc and attempting to store the value from one of the columns in an int primitive. However, occasionally this value is NULL in the db, and attempting to store a null in an int throws an NPE. Is there a function (like Javascript's isNaN) that I can use to test the ResultSet value, and if null, assign -1 or something to the int var instead? I've searched these forums, Google, and the docs, but get back thousands of results for strings like 'null int ResultSet', and don't see the answer in the top few results. Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 27 2006
Added on Jul 25 2006
57 comments
808 views