I need to retrieve a double value from a database, which could potentially be stored as null, so I need to detect whether or not it is null before or after retrieving it. However, the method getDouble("columnName") actually returns 0 if the value in the database is null.
I have tried the solutions provided here to no avail (Android Studio says it's unable to resolve wasNull() and getObject():
How do I in JDBC read a possibly null double value from resultSet?
Here is what I've tried so far:
beer.setRating(beerObj.getDouble("myRating"));
if(beerObj.wasNull()){ //'Cannot resolve method wasNull'
}
And this:
Double doubleVal = (Double)beerObj.getObject("myRating"); //'Cannot resolve method getObject()'
I have other properties that I am retrieving using getString("otherColumnName") and that is retrieved properly so I assumed that the beerObj was retrieved properly as well.
Is there another way to check if the double value is null in the database before retrieving it?