Bug #44324 Data Truncation Exception Error Code is not proper
Submitted: 16 Apr 2009 14:40 Modified: 16 Sep 2009 13:40
Reporter: Saminathan Arumugam Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:5.1.7 OS:Linux
Assigned to: Mark Matthews CPU Architecture:Any
Tags: "data truncation", 1265, connector

[16 Apr 2009 14:40] Saminathan Arumugam
Description:
SQLException for data truncation error gives the error code as zero instead of 1265

How to repeat:
Use MySQL Connector jar 3.1.13 with MySQL 4.1.22. SQLException for data truncation error gives the error code as zero instead of 1265. Use the method getErrorCode() in SQLException. Check with data truncation error, it returns '0' instead of 1265.
[16 Apr 2009 14:44] Tonci Grgin
Hi Saminathan and thanks for your report.

v 3.1 is EOL-ed long long ago. Please upgrade your c/J.
[17 Apr 2009 4:14] Saminathan Arumugam
Even the connector 5.1.7 gives the error code as '0' for data truncation !!
[18 Apr 2009 6:52] Saminathan Arumugam
Even the connector 5.1.7 gives the error code as '0' for data truncation !!
[20 Apr 2009 8:44] Tonci Grgin
Thanks Saminathan, reopening for investigation.
[20 Apr 2009 10:15] Tonci Grgin
Test case for our test framework.

Attachment: TestBug44324.java (text/x-java), 2.39 KiB.

[20 Apr 2009 10:17] Tonci Grgin
Verified as described using latest c/J 5.1 sources and attached test case.
Test case output:
Loading JDBC driver 'com.mysql.jdbc.Driver'
Done.

Done.

Connected to 5.1.31-log
java.vm.version         : 1.5.0_17-b04
java.vm.vendor          : Sun Microsystems Inc.
java.runtime.version    : 1.5.0_17-b04
os                      : Windows Server 2008, 6.0, x86
sun.management.compiler : HotSpot Client Compiler
-------------------------------------------------
State: 01004
ErrCode: 0
Done

Workaround is to use JDBCCompliantTruncation=false.
[20 Aug 2009 20:21] Mark Matthews
Fixed for 5.1.9. The fix does not hard-code to 1265 because the server returns different error codes for different types of truncations, and we did not want to mask those.
[16 Sep 2009 13:40] Tony Bedford
An entry was added to the 5.1.9 changelog:

SQLException for data truncation error gave the error code as 0 instead of 1265.