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 Handling null numeric values in a result set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Handling null numeric values in a result set" Watch "Handling null numeric values in a result set" New topic
Author

Handling null numeric values in a result set

Bill Hamlin
Greenhorn

Joined: Jun 20, 2008
Posts: 1
I'm trying to write a generic object factory class that I can run against a database table and produce an object with a constructor, getters, setters and methods to test if values have changes and to save changes to the table.

I've always been a little weak on how to handle numeric values, since the jdbc getters (getInt, getDouble, etc) return zero if the database value is null.

I'm aware of the wasNull test, but in order to use it I guess I'll have to create my objects using objects like Integer and Double in place of the primitives like int and double (which is what I have to use in my result set getters).

Anybody have any advice on a best practice for handling this sort of thing? I obviously don't want to be setting real values (zeros) to null fields when I do updates!

Any help or suggestions would be appreciated!

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling null numeric values in a result set