2

In Postgresql table we have field with type numeric(10, 2). When I try to select data from this field

select amount from vc_cashouts where id = 25721

I get this result (other records are correct):

org.postgresql.util.PSQLException: Bad value for type BigDecimal : NaN

How can I correct this result? I need to export data from this column to file and i need to replace this NaN to for example default value

0

1 Answer 1

1

I assume you are using ResultSet.getBigDecimal() to retrieve that value.

A BigDecimal can't represent NaN - only java.lang.Double can do that.

You need to change your code to use ResultSet.getDouble() or ResultSet.getObject() - the latter will return a BigDecimal or a Double.NaN depending on the value in the database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.