MySql UTF encoding

試著忘記壹切 提交于 2019-12-10 16:35:50

问题


 java.sql.SQLException: Incorrect string value: '\xAC\xED\x00\x05sr...' for column 'xxxx'

The column is a longtext in MYSQL with utf8 charset and utf8_general_ci collation.

What is wrong?


回答1:


It's a bit late, but you might want to know that \xAC\xED\x00\x05sr... is a magic number for Java serialization. Apparently your parameter is being serialized instead of being pasted as a string.




回答2:


Assuming that those are hexadecimal escape codes, the text \xAC\xED\x00\x05sr... is not a valid UTF-8 string.




回答3:


Is this while using PreparedStatements in Groovy? If so, you're using GStrings instead of plain Java Strings. Check your object yo make sure your parameters are what you expect.




回答4:


change your table to latin1 encoding or utf8mb4




回答5:


ALTER TABLE your_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

You can try this.



来源:https://stackoverflow.com/questions/2687164/mysql-utf-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!