Обсуждение: JDBC and BigDecimal problem

Поиск
Список
Период
Сортировка

JDBC and BigDecimal problem

От
Peter Figuli
Дата:
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