JDBC and BigDecimal problem - Mailing list pgsql-bugs

From Peter Figuli
Subject JDBC and BigDecimal problem
Date
Msg-id 1025626893.23160.29.camel@peposh
Whole thread Raw
List pgsql-bugs
Dear JDBC team,

I'm using pgjdbc2.jar from february and facing this problem:
I have a table (UNICODE database is set up) having numeric type in it.
Than something like this:

statement = connection.preparedStatement( "SELECT * from account WHERE
rate > ?" );
statement.setBigDecimal( 1, BigDecimal.valueOf( 120, 2 ));

produces postgresql error:
ERROR: Unable to identify an operator '>' for numeric and double
precision.

Because we use some data object persistent software, there is a problem
force program to do any cast for it.

My simple hack is based on fact that:
SELECT * from account WHERE rate > '1.2';
avoids double conversion of '1.2' I changed:
org.postgresql.jdbc2.PreparedStatement.java on line 254 (
setBigDecimal(...)) from:
set(parameterIndex, x.toString()); to:
set(parameterIndex, "'"+x.toString()+"'");

All seems to work properly now.


Nice day

Peposh

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Problem
Next
From: Peter Figuli
Date:
Subject: Unicode collation error.