If you get the place where NULL is entered in DB with the code of ↓, It became 0 instead of null.
Double d = rs.getDouble(1);
System.out.println(d);//"0.0"Is output
When I check it, the return value of getDouble is not Double but double ... ↓ Source ResultSet (Java Platform SE 8 )
Return value:
Column value. If the value is SQL NULL, the value returned is 0
After clarifying, the following method seems to return null other than null.
wasNull After reading with getXxxx There is also a method that can check if it is null, It's hard to use the past form instead of isNull ...
After all, it was solved with ↓
Double d = (Double)rs.getObject(1);
System.out.println(d);//Output as null
Don't use JDBC directly, use some kind of persistence framework.
Recommended Posts