Bug #21990 | DECIMAL datatype PreparedStatement Java JDBC | ||
---|---|---|---|
Submitted: | 4 Sep 2006 10:03 | Modified: | 13 Sep 2006 7:30 |
Reporter: | Stefan Duffner | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / J | Severity: | S2 (Serious) |
Version: | 3.1.3, 5.0.3 | OS: | Windows (Windows2000) |
Assigned to: | CPU Architecture: | Any |
[4 Sep 2006 10:03]
Stefan Duffner
[13 Sep 2006 7:30]
Tonci Grgin
Hi Stefan and thank you for your problem report. It do sound weird and I was unable to repeat it (not with 81.65 nor with any other value): this.pstmt.setString(1, "1"); this.pstmt.setDouble(2, 81.65); System.out.println("Query to be executed: "+pstmt.toString()); assertEquals(1, this.pstmt.executeUpdate()); this.pstmt.clearParameters(); I presume what's happening is that you're using double variable incremented in steps but double arithmetics is far from perfect as you can se from my next example: double i = 0.00; String s = ""; while (i < 150.00) { s = Double.toString(i*10); this.pstmt.setString(1, s); this.pstmt.setDouble(2, i); System.out.println("Query to be executed: "+pstmt.toString()); assertEquals(1, this.pstmt.executeUpdate()); this.pstmt.clearParameters(); i = i + 0.01; } ... Query to be executed: com.mysql.jdbc.ServerPreparedStatement[1] - insert into test_table (OID,HEIGHT) values ('0.5', 0.05); Query to be executed: com.mysql.jdbc.ServerPreparedStatement[1] - insert into test_table (OID,HEIGHT) values ('0.6000000000000001', 0.060000000000000005); ... This is in no way connector's or server problem. Putting jdbcCompliantTruncation=false into connection string supresses reported warning as it is it's job, so nothing weird there. Environment: MySQL server 5.0.24 BK on WinXP Pro SP2 localhost connector/J 5.0 SVN JDK 1.5.07