Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 6C50B9F95B8 for ; Wed, 5 Sep 2007 06:27:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 50668-02 for ; Wed, 5 Sep 2007 06:27:21 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.185]) by postgresql.org (Postfix) with ESMTP id 65E319F95B6 for ; Wed, 5 Sep 2007 06:27:20 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id l15so1289475rvb for ; Wed, 05 Sep 2007 02:27:19 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=QWHUyo7yTbDFp6dS7B1+aznNnN63fiwiX6Y6SLXyDpOonnqE4oY3FWrkaRn38ngEo38hS0/VrS6CPMod4zeyaqZLcvqxvTILwbVXHIEDtrTApU2ezDImZp5bUYLTQ8GF2HC44vA6+gUyIW7RqOz9IurVOLRxh+qNJPFXXMihOts= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=MOOHbr9aI9bF97ZBQEvhscWqnRSWkRhQPzFGqG/gmFoD6DV3vdjBhY6FCxkfELLcqXTroGslQBd07uod+RkF9RQKIpcEV9xY8wivsLhrKIB/6VNZLhecVvecTnqscG+Wcnc4IyG8oNXM0wLbqZnx6V/CmT/BPKFRim21JJ3jXfA= Received: by 10.141.14.14 with SMTP id r14mr2746022rvi.1188984439382; Wed, 05 Sep 2007 02:27:19 -0700 (PDT) Received: by 10.141.69.7 with HTTP; Wed, 5 Sep 2007 02:27:19 -0700 (PDT) Message-ID: Date: Wed, 5 Sep 2007 11:27:19 +0200 From: "Peter Kovacs" To: pgsql-jdbc@postgresql.org Subject: PreparedStatement rounds doubles to scale 14 during update MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 7cba6b3cebf58304 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/13 X-Sequence-Number: 17435 Hi, I have the following problem with postgresql-8.1-407.jdbc3.jar used against a 8.1 version backend. A table "chemterms_cols_test" has a column "logp" defined as: logp numeric(30,17) The double value 6.118992224252588 gets rounded to 6.11899222425259000 during updates with PreparedStatements using place-holder. (There is no rounding with Statement and the value specified in the SQL literally.) Is this the expected behaviour? Below is the code that can be used to test this behaviour ("cd_id" is the primary key): public static void main(String[] args) { try { Connection conn = DBTools.getConnectionHandler().getConnection(); conn.setAutoCommit(false); int cdId = 1; double dblValue = 6.118992224252588; String sql = "update chemterms_cols_test set logp = ? where cd_id = ?"; try { PreparedStatement pstmt = conn.prepareStatement(sql); try { pstmt.setDouble(1, dblValue); pstmt.setInt(2, 1); pstmt.executeUpdate(); conn.commit(); } finally { pstmt.close(); } ResultSet rs = null; sql = "select logp from chemterms_cols_test where cd_id = ?"; pstmt = conn.prepareStatement(sql); try { pstmt.setInt(1, 1); rs = pstmt.executeQuery(); rs.next(); double actual = rs.getDouble(1); System.out.println("actual=" + actual + ", expected=" + dblValue + ", equals? : " + (actual == dblValue)); } finally { try { if (rs != null) { rs.close(); } } finally { pstmt.close(); } } } finally { conn.close(); } } catch (Throwable tbl) { tbl.printStackTrace(); System.exit(1); } } Thanks Peter