Bug #3804 getWarnings() returns SQLWarning instead of DataTruncation
Submitted: 17 May 2004 21:34 Modified: 4 Aug 2004 16:39
Reporter: Antoine Martin Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.1alpha OS:Linux (Linux 2.6.6 - glibc 2.3.2)
Assigned to: Mark Matthews CPU Architecture:Any

[17 May 2004 21:34] Antoine Martin
Description:
On insert of an overflow string into a varchar(255) column, the driver returns a SQLWarning:
warning[0]= class java.sql.SQLWarning message=Data truncated for column 'TESTVC'
at row 1, sql state=S1000, error code=1264

when according to the jdbc spec, it should return:
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DataTruncation.html

I have worked around it using sql state and error code to detect the warning.

More details are available (including some sample test code) in bug 3697:
http://bugs.mysql.com/bug.php?id=3697&error=bc

How to repeat:
Insert a too long string in a varchar(255) column using jdbc and get the warnings.

Suggested fix:
The detection should go in the jdbc driver and return a DataTruncation
[8 Jun 2004 17:46] Mark Matthews
This is fixed in the source repository, and will be available in C/J 3.1.2.
[4 Aug 2004 16:39] Mark Matthews
Thank you for your bug report. This issue has already been fixed
in the latest released version of that product, which you can download at 
http://www.mysql.com/downloads/