Java+mysql Handling of emoticons

Source: Internet
Author: User

Error Environment:

MySQL 5.0: UTF8 encoding

Jdbc:mysql-connector-java-5.1.5-bin.jar


Error in case of emoticons:

Java.sql.SQLException:Incorrect string value: ' \xf0\x9f\x98\x84 ' for column


Because the emoji in some terminals, such as ios5.0 above, is expressed in four bytes, and the traditional UTF8 can only save 3 bytes, so the error.


The correct solution is as follows:

1, MySQL database upgrade to more than 5.5;

2, the database, the table, the field byte code rises from UTF8 to utf8mb4;

Refer to: HTTPS://MATHIASBYNENS.BE/NOTES/MYSQL-UTF8MB4#UTF8-TO-UTF8MB4

3, upgrade JDBC;


Lab Environment:

MySQL 5.5.39

jdbc:mysql-connector-java-5.1.30



Java+mysql Handling of emoticons

Related Article

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.