I have a column in my database that is typed double
and I want to read the value from it using a JDBC ResultSet, but it may be null. What is the best way of doi
Option 1 is closest:
double d = rs.getDouble(1);
if (rs.wasNull()) {
// do something
} else {
// use d
}
It's not very nice, but that's JDBC. If the column was null, the double value is considered "bad", so you should check using wasNull()
every time you read a primitive that is nullable in the database.