How do I get a Double out of a resultset instead of double?

java, jdbc

Solution

You can check for `wasNull` on your ResultSet to find out if the value was `null`.

Note that you must first call one of the getter methods on a column to try to read its value and then call the method wasNull to see if the value read was SQL NULL.

If you really need a `Double` afterwards, you can create it from the `double` returned.

Problem

When working with a JDBC resultset I want to get Double instead of double since this column is nullable. Rs.getDouble returns 0.0 when the column is null.

Original source