2 messages in com.mysql.lists.javare: data truncation error using Mysql...
FromSent OnAttachments
James Black22 Sep 2004 10:03 
Mark Matthews23 Sep 2004 06:45 
Subject:re: data truncation error using Mysql 5.0.1alpha-snapshot and Connector/J 3.1.4b
From:Mark Matthews (ma@mysql.com)
Date:09/23/2004 06:45:03 AM
List:com.mysql.lists.java

Hello,

I just upgraded both parts and am running my unit tests, and I am getting a data truncation error.

The column is of char[2] and I am trying to put into it a value of '00'.

Any idea why I would be getting this error?

Thanx.

James,

I've tried to repeat your issue with MySQL and 5.0.2 and Connector/J 3.1.4 locally here, and can't repeat it. Is there any chance you can take a look at the following test case and point out anything that is different you are doing that might be causing the bug.

public void testTruncationWithChar() throws Exception { try { this.stmt.executeUpdate("DROP TABLE IF EXISTS testTruncationWithChar"); this.stmt.executeUpdate("CREATE TABLE testTruncationWithChar (field1 char(2))");

this.pstmt = this.conn.prepareStatement("INSERT INTO testTruncationWithChar VALUES (?)"); this.pstmt.setString(1, "00"); this.pstmt.executeUpdate(); } finally { this.stmt.executeUpdate("DROP TABLE IF EXISTS testTruncationWithChar"); } }

-Mark