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

From Hervé Hénoch
Subject Postgresql8.4 + floats with jdbc driver postgresql-8.4-701.jdbc4.jar
Date
Msg-id 4BD599A6.9080504@isc84.org
Whole thread Raw
List 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

pgsql-jdbc by date:

Previous
From: Achilleas Mantzios
Date:
Subject: Re: Very Dangerous bug in XA connection pooling and SL EJBs with jboss-4.2.3 & latest postgresql-8.4-701.jdbc3.jar
Next
From: Andrew Brunette
Date:
Subject: Connection problems with jdbc