JDBC 9.2: multiple execution of prepared statement-query delivers different double precision results via getString() - Mailing list pgsql-jdbc

From Tilman Sandig
Subject JDBC 9.2: multiple execution of prepared statement-query delivers different double precision results via getString()
Date
Msg-id 004201ceb098$2d6d79f0$88486dd0$@com
Whole thread Raw
Responses Re: JDBC 9.2: multiple execution of prepared statement-query delivers different double precision results via getString()
List pgsql-jdbc
Hello,

there might be a problem in the latest JDBC-driver (9.2 build 1003) when querying double precision-result columns
multipletimes 
and retrieving the result with ResultSet.getString():

The first five queries work as expected, further calls append ".0" to the result-string.

Here is a sample code:

PreparedStatement stmt = myConnection.prepareStatement("select cast(1 as double precision)");
for (int x=0;x<12;x++){
    ResultSet rs = stmt.executeQuery();
    while (rs.next()){
        System.out.println("Value: " + rs.getString(1));
    }
}

-------
Output:
-------

Value: 1
Value: 1
Value: 1
Value: 1
Value: 1
Value: 1.0
Value: 1.0
Value: 1.0
Value: 1.0
Value: 1.0
Value: 1.0
Value: 1.0


The problem does not occur when using JDBC-driver version 9.1;
I use PostgreSQL Version 9.3.0 (Win64/Vista)

Best regards,
  Tilman Sandig



pgsql-jdbc by date:

Previous
From: Vitalii Tymchyshyn
Date:
Subject: Re: Using CopyManager with pooled JCA connection
Next
From: Mikko Tiihonen
Date:
Subject: Re: JDBC 9.2: multiple execution of prepared statement-query delivers different double precision results via getString()