Data truncation: data too long for column 'id' at Row 1

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.