Discussion Locked

NULL values in a database

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Tell us what you think about the wasNULL method, as featured in the August 19th Java e-newsletter. Have you experienced this subtle bug that's hidden in the ResultSet class?

4 replies

by eamonn_casey

wasNull is terrible!

1. wasNull is AFTER you read the data, so you must place the eventual assignment after the check for wasNull to avoid NULL being assigned.
2. I think that this is the only wasXXX() function in the SDK. Try finding it when all of the other functions are called isXXX()

by java guru

1) I prefer to not allow nulls into the DB.
2) use isnull() in the DB
3) solve in the middle tier via (if, wasnull, etc).

I think solving it in the middle tier is the least desireable. Having null values floating around can only cause trouble. I usually design them away in the beginning.

by dave_rabone

any of his books ... they tend to have rehashes of the same articles. "Relational Database Writings"*

by bayard-generationjava

1) I'd love a db without null in there. Lots of NOT NULLs
are nice, but legacy databases or differing opinions can
mean otherwise.

2) I hate to use database functions as I've never found
them very independent. Nicer to have a reusable db
layer with wasNulls.

3) Agreed that this is a pain, I'd go 1, then 3 then 2.
Unless it's specific code, in which case 1, 2, 3.

This discussion is closed to new replies.