3

I need to know if value (numeric) in Java ResultSet from PostgreSQL is NULL and if so, I would need to get Double.NaN instead of 0. I use Apache Commons DBUtils mapping but it maps NULL value to 0.

Is there some way how to get Double.NaN instead without need to create own BasicRowProcessor?

jnemecz
  • 3,171
  • 8
  • 41
  • 77
  • I strongly suspect you'll have to override or replace the underlying code. It would be completely incorrect for PgJDBC to return `Double.NaN` for `null`, since `NaN` is a legal non-null value for a float column. Why don't you just store `NaN` in the database anyway? Is it because (for some insane, wtf-were-you-thinking reason) Java's BigDecimal can't cope with `NaN`? – Craig Ringer Apr 05 '15 at 11:32
  • You are right, it doesn't have to be `Double.NaN` but I need to know, if original value in database table is `NULL` or `0`. Mapping I use from DBUtils makes `0` from `NULL` (missing value) what makes issues in my code. – jnemecz Apr 05 '15 at 12:18
  • check this out : http://stackoverflow.com/questions/2158187/how-do-i-get-a-double-out-of-a-resultset-instead-of-double – HsnVahedi May 21 '16 at 09:44

0 Answers0