Postgresql8.4 + floats with jdbc driver postgresql-8.4-701.jdbc4.jar

From: Hervé Hénoch <h(dot)henoch(at)isc84(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Postgresql8.4 + floats with jdbc driver postgresql-8.4-701.jdbc4.jar
Date: 2010-04-26 13:48:22
Message-ID: 4BD599A6.9080504@isc84.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,

We have a strange behavior when running this code :

public static void main(String[] args) {

try {
Class.forName("org.postgresql.Driver");
Properties props = new Properties();
props.setProperty("user", "postgres");
props.setProperty("password", "mypassword");
Connection _connexion = DriverManager.getConnection(
"jdbc:postgresql://<ip>:5432/personnel", props);

_connexion
.prepareStatement(
"create temporary table test_oliv (val
real);insert into test_oliv(val) values (1.8);"
+ "insert into test_oliv(val) values
(1.8);insert into test_oliv(val) values (1.8);")
.execute();

ResultSet rs = _connexion.prepareStatement(
"select sum(val) as t from test_oliv;").executeQuery();
rs.next();
System.out.println("Float: " + rs.getFloat("t"));
System.out.println("Double: " + rs.getDouble("t"));
System.out.println("Object: " + rs.getObject("t"));

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

The results are :

Float: 5.3999996
Double: 5.3999996
Object: 5.3999996

With 8.2 driver the results are rights.

Idea ?

Regards

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andrew Brunette 2010-04-27 23:38:18 Connection problems with jdbc
Previous Message Achilleas Mantzios 2010-04-26 11:49:12 Re: Very Dangerous bug in XA connection pooling and SL EJBs with jboss-4.2.3 & latest postgresql-8.4-701.jdbc3.jar