I am working with the Postgres JDBC driver (postgresql-42.2.5.jar) and PostgreSQL 10.6 RDBMS.
I have a result set, and 3 of its columns are of type money
(on the DB level). And I have a result set meta data object.
When the column type is money, the driver's method
getColumnType() returns 8 for the money
columns.
I checked, value of 8 means Double.
But the value returned from the DB is something like
$1,312,536.00
or say 1,312,536.00
.
So when I try to call rs.getObject() on that column index, it errors out with this:
org.postgresql.util.PSQLException: Bad value for type double: 1,312,536.00
at org.postgresql.jdbc.PgResultSet.toDouble(PgResultSet.java:2934)
at org.postgresql.jdbc.PgResultSet.getDouble(PgResultSet.java:2323)
at org.postgresql.jdbc.PgResultSet.internalGetObject(PgResultSet.java:194)
at org.postgresql.jdbc.PgResultSet.getObject(PgResultSet.java:2572)
at org.apache.commons.dbcp2.DelegatingResultSet.getObject(DelegatingResultSet.java:733)
at org.apache.commons.dbcp2.DelegatingResultSet.getObject(DelegatingResultSet.java:733)
So it seems the driver cannot talk to its own DB when it comes to money type.
This seems like a bug to me.
Seems that PG-JDBC, they had a bug open for this
https://github.com/pgjdbc/pgjdbc/issues/100
but they closed it due to lack of response instead of fixing it.
Any ideas how to solve this?
Is it really a bug or am I missing something?