Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column ‘titleimg‘ at row 1 at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1269) at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:955) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268) ... 75 more10437 ERROR [2013-04-15 17:22:49]
Example: The error does not occur because the field is too long,
1. It may be because the character set of the table in the database is different.
2. It may be true that the database in the database field is indeed too long (I encountered this situation ).
For example, utf8 tables and gbk_chinese_ci tables exist in the same database.
Solution: alter table 'cms _ activity_test 'convert to Character Set GBK collate gbk_chinese_ci; (modify the character set of the specified table separately)
Supplement: by searching for information on the Internet, you can modify the default Character Set of MySQL database and the character set of a single database.
1. Find the my. ini file in the MySQL database directory, CTRL + F find character-set, and modify
[client]port=3306[mysql]default-character-set=utf8
2. Modify the character set of a single database, locate the DB. Opt file in the data directory, and then modify
default-character-set=gbkdefault-collation=gbk_chinese_ci
3. Use commands to set
mysql> SET character_set_client = utf8 ;mysql> SET character_set_connection = utf8 ;mysql> SET character_set_database = utf8 ;mysql> SET character_set_results = utf8 ;mysql> SET character_set_server = utf8 ;mysql> SET collation_connection = utf8 ;mysql> SET collation_database = utf8 ;mysql> SET collation_server = utf8 ;
4. if it is too troublesome, you can use a stupid method. If the entire database table is small and the data volume is small, you can export the entire database, then, modify the tables with different character sets in the file, and import them to the database...
Data truncation: data too long for column 'id' at Row 1