PreparedStatement & SUM - Floating Point Issues
I'm experiencing what appear to be floating point issues when using PreparedStatements.
I've created a small test harness to help track down the problem. FYI, period_no is an int(11) unsigned and amount_paid is a decimal(10, 2).
Firstly running this query :
SELECT sum(period_no) FROM aofe_payments WHERE aofe_id = 44
Returns this :
Executing Statement query...
Result : 21
Executing PreparedStatement query...
Result : 21.0
Secondly, running this query :
SELECT sum(amount_paid) FROM aofe_payments WHERE aofe_id = 44
Returns this :
Executing Statement query...
Result : 584.84
Executing PreparedStatement query...
Result : 584.8399999999999
I've tried updating the server & driver versions, and thus my test environment now looks like this:
Database: MySQL 4.1.14-nt
Driver: MySQL-AB JDBC Driver mysql-connector-java-3.1-nightly-20050823 ( $Date: 2005-08-12 21:19:36 +0000 (Fri, 12 Aug 2005) $, $Revision: 4067 $ )
Any help appreciated!
Kevin Lloyd
Subject
Written By
Posted
PreparedStatement & SUM - Floating Point Issues
August 26, 2005 03:32AM
September 02, 2005 07:29PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.