MySQL数据截断错误 [英] MySQL Data Truncation Error
问题描述
我正在使用Java应用程序中相当简单的数据库。我们尝试使用标准的JDBC mysql适配器一次插入大约200k的文本。我们间歇性地得到一个com.mysql.jdbc.MysqlDataTruncation:数据截断:列错误的数据太长。
I'm working with a fairly simple database, from a Java application. We're trying to insert about 200k of text at a time, using the standard JDBC mysql adapter. We intermittently get a com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column error.
列类型为longtext,数据库排序规则为UTF-8。使用MyISAM和InnoDB表引擎显示错误。客户端和服务器端的最大数据包大小已设置为1 GB,因此也不会导致问题。
The column type is longtext, and database collation is UTF-8. The error shows up using both MyISAM and InnoDB table engines. Max packet size has been set ot 1 GB on both client and server sides, so that shouldn't be causing a problem, either.
推荐答案
检查您的UTF-8数据是否都是3字节Unicode。如果您有4个字节的字符(在Unicode和Java中是合法的,在MySQL 5中是非法的),当您尝试插入它们时,它会抛出此错误。这是MySQL 6.0中的应修复的问题。
Check that your UTF-8 data is all 3-byte Unicode. If you have 4-byte characters (legal in Unicode and Java, illegal in MySQL 5), it can throw this error when you try to insert them. This is an issue that should be fixed in MySQL 6.0.
这篇关于MySQL数据截断错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!