mysql存表情出錯的解決方案(類似\xF0\x9F\x98\x86\xF0\x9F)


之前以為mysql設置utf-8以及昵稱decode后就萬事大吉了,結果最近才發現對於4字節的表情會報錯。

 

報錯信息如下:

data: null
message: " ### Error updating database. Cause: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x86\xF0\x9F...' for column 'nickName' at row 1 ### The error may involve com.smallfoxdog.demo.mapper.UserMapper.insertUser-Inline ### The error occurred while setting parameters ### SQL: insert into users(id,wxOpenid,nickName,avatarUrl,gender,province,city,country,continue_days) values(NULL,?,?,?,?,?,?,?,1) ### Cause: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x86\xF0\x9F...' for column 'nickName' at row 1 ; uncategorized SQLException; SQL state [HY000]; error code [1366]; Incorrect string value: '\xF0\x9F\x98\x86\xF0\x9F...' for column 'nickName' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x86\xF0\x9F...' for column 'nickName' at row 1"
status: 200
timestamp: 1526283581431
__proto__: Object
errMsg: "request:ok"
header: Object

 

解決方案:https://blog.csdn.net/yown/article/details/52627223(注:他里面有2個sql我執行失敗,但是一樣也改好了)

 

但是看其他帖子說數據庫連接的時候去掉編碼格式,目前我的鏈接地址如下,去掉了characterEncoding=utf8,測試成功

 

 

下面是修改后游戲中的效果已經可以正常顯示表情了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM