JDBC and BigDecimal problem

From: Peter Figuli <peposh(at)peposh(dot)sk>
To: pgsql-bugs(at)postgresql(dot)org
Subject: JDBC and BigDecimal problem
Date: 2002-07-02 16:21:33
Message-ID: 1025626893.23160.29.camel@peposh
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2002-07-02 19:03:57 Re: Problem
Previous Message Peter Figuli 2002-07-02 16:11:06 Unicode collation error.