Special characters cannot be stored

 Error phenomenon:

org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO B_ITEM_ORDER66            (ORDER_SERIAL_NUMBER,ORDER_CODE,ITEM_CODE,ITEM_NAME,B_CUST_NO,S_CUST_NO,          UNIT_PRICE,NUMBER,FREIGHT_PRICE,TOTAL_PAY_PRICE,PAYMENT_METHOD,     ORDER_STATUS,CUST_NAME,MEMBER_PHONE,S_ADDRESS,CREATE_TIME,     LASTUP_TIME,B_MESSAGE,EVALUATION_STATUS,TRANSPORDCODE,ORDER_SOURCE)          VALUES (?,?,?,?,?,?,          ?,?,?,?,?,     ?,?,?,?,?,     ?,?,?,?,?)]; SQL state [HY000]; error code [1366]; Incorrect string value: '\xF0\x9F\x99\x8F\xF0\x9F...' for column 'B_MESSAGE' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xF0\x9F\x99\x8F\xF0\x9F...' for column 'B_MESSAGE' at row 1

 

reason:

\xF0\x9F\x99\x8F\xF0\x9F is hexadecimal, and the default character set encoding of the database is utf8, which cannot recognize hexadecimal data.

 

Solution:

Upgrade the character set of the database from utf8 to utf8mb4.

 

Upgrade plan:

  1. Modify the database character set character-set-server=utf8mb4 and restart the database to take effect.

  2. Modify the character set of the database to utf8mb4 alter database dbname character set utf8mb4

  3. Modify the character set of the table to utf8mb4, alter table character set = utf8mb4

 

ALTER TABLE bargain_msg_receive CONVERT TO CHARACTER SET utf8mb4;

 

http://vivisidea.iteye.com/blog/1395571

 http://www.jianshu.com/p/20740071d854

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326494701&siteId=291194637