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

來源:互聯網
上載者:User

標籤:png   我的連結   rac   har   message   users   sof   span   mysq   

之前以為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

 

解決方案:52627223(註:他裡面有2個sql我執行失敗,但是一樣也改好了)

 

但是看其他文章說資料庫連接的時候去掉編碼格式,目前我的連結地址如下,去掉了characterEncoding=utf8,測試成功

 

 

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

 

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.