Postgres, for example, allows NaN and infinity values on numeric columns (with 
some exclusions).

When we try read these, we get:

org.apache.metamodel.MetaModelException: Could not get next record in 
resultset: Bad value for type BigDecimal : NaN
        at org.apache.metamodel.jdbc.JdbcUtils.wrapException(JdbcUtils.java:61)
        at org.apache.metamodel.jdbc.JdbcDataSet.next(JdbcDataSet.java:141)

. . .

Caused by: org.postgresql.util.PSQLException: Bad value for type BigDecimal : 
NaN
        at org.postgresql.jdbc.PgResultSet.toBigDecimal(PgResultSet.java:2880)
        at org.postgresql.jdbc.PgResultSet.toBigDecimal(PgResultSet.java:2889)
        at org.postgresql.jdbc.PgResultSet.getBigDecimal(PgResultSet.java:2332)
        at 
org.postgresql.jdbc.PgResultSet.internalGetObject(PgResultSet.java:192)
        at org.postgresql.jdbc.PgResultSet.getObject(PgResultSet.java:2571)
        at 
org.apache.metamodel.jdbc.dialects.AbstractQueryRewriter.getResultSetValue(AbstractQueryRewriter.java:461)

In our previous code, we would try these as BigDecimal, and if a SQL exception 
occurred, we would retry it with ResultSet.getDouble() which works because 
Double supports both Nan and Infinite values.

Can you suggest a work-around or fix? We have thought of a couple, but because 
database vendors differ in their support for NaN and Infinite values, none of 
them are very appealing.

Best,
Dana

Reply via email to