Re: JDBC Driver42.2.2 throws error when dealing with money datatype

From: "Suwalka, Kriti" <ksuwalka(at)informatica(dot)com>
To: Dave Cramer <davecramer(at)gmail(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: JDBC Driver42.2.2 throws error when dealing with money datatype
Date: 2018-06-05 02:39:58
Message-ID: BN6PR03MB32846A3A41E5CE5311A043C8C7660@BN6PR03MB3284.namprd03.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Dave,

Thanks for the response ??. Any work-around available? Or any plan to fix it ?

Regards,
Kriti

Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Dave Cramer <davecramer(at)gmail(dot)com>
Sent: Monday, June 4, 2018 11:31:58 PM
To: Suwalka, Kriti
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: JDBC Driver42.2.2 throws error when dealing with money datatype

Hello,

Well that truly is a bug, and shouldn't happen.

Thanks

Dave Cramer

On 4 June 2018 at 11:47, Suwalka, Kriti <ksuwalka(at)informatica(dot)com<mailto:ksuwalka(at)informatica(dot)com>> wrote:
Hi,

I was trying to read a table with money column using JDBC driver(version 42.2.2). JDBC driver returns data type as double and it internally tries to use ResultSet.getDouble when ResultSet.getObject() is used.

Please find the details below
Database version : 9.6
Driver version : 42.2.2
Table DDL: create table src_money(col1 money);
Insert DML : insert into src_money values(1000);

JDBC Code Snippet:
String sqlQuery = "select * from src_money";
PreparedStatement stmt = con.prepareStatement(sqlQuery);
ResultSet readRs = stmt.executeQuery();
while(readRs.next()) {
System.out.println(readRs.getObject(1));
}

JDBC Code Output:
org.postgresql.util.PSQLException: Bad value for type double : 1,000.00
at org.postgresql.jdbc.PgResultSet.toDouble(PgResultSet.java:2930)
at org.postgresql.jdbc.PgResultSet.getDouble(PgResultSet.java:2317)
at org.postgresql.jdbc.PgResultSet.internalGetObject(PgResultSet.java:194)
at org.postgresql.jdbc.PgResultSet.getObject(PgResultSet.java:2568)
at jdbc_sample_latest.PostgresSSL.main(PostgresSSL.java:74)

What is the fix or work-around here to get rid of this error? My application is a generic application and I expected that driver would take care of retrieving money data type when using ResultSet.getObject() but unfortunately driver isn’t working as expected.

P.S.> I have seen the discussion on the same issue on forum but couldn’t find a solution for the same.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Kellerer 2018-06-05 06:19:01 Re: JDBC Driver42.2.2 throws error when dealing with money datatype
Previous Message Thomas Munro 2018-06-04 23:06:02 Re: BUG #15225: [XX000] ERROR: invalid DSA memory alloc request size 1073741824 / Where: parallel worker