Error when inserting data: # # # Error updating database. Cause:Java.sql.SQLException:Incorrect string value: ' \xf0\x9f\x98\x84 ' for column ' Bak2 ' at row 1
This is because: the emoji emoji on the mobile side is 4 bytes, and MySQL's UTF8 encoding is up to 3 bytes, so it's not plugged in.
Workaround:
1: Let the user mainstream, remove those messy expression ... Unlikely
2: Filter out non-mainstream characters ... Not very human
3: The MySQL encoding from UTF8 to UTF8MB4, you can fundamentally solve the problem, specifically how to convert the following articles for reference:
Http://www.it165.net/database/html/201405/6581.html
Http://www.it165.net/database/html/201408/7544.html
Http://www.it165.net/database/html/201408/7550.html
HTTP://WWW.W 2 bc.com/article/8533
4: My solution: Because the database has been built, with a large number of formal data, security, I was by transcoding the way to solve, warehousing before encode a bit, out of the library before decode a bit. Although it is a little cumbersome, the problem can be solved.
Through this matter, give me the revelation: in the rapid development of mobile Internet today, in order to avoid the emoji expression of the failure problem, involving the mobile-related database in the table before the proposed use of the UTF8MB4 character set.
http://m.blog.csdn.net/blog/everything_is_ok/42454451
Emoji emoji on mobile end failed to insert into MySQL database