mysql字符集设置遇到的问题
这两天在捣鼓我的moon,为其在mysql上建了个库,但往数据库insert时报了如下错误
(java程序报错,workbench里直接使用insert 语句没问题,但显示为乱码)
--- The error occurred in ibatis/moon-knowledge.xml. --- The error occurred while applying a parameter map. --- Check the com.ymkyve.moon.pojo.Knowledge.create-InlineParameterMap. --- Check the statement (update failed). --- Cause: java.sql.SQLException: Incorrect string value: '/xE4/xB8/xAD/xE8/xBD/xBC...' for column 'title' at row 1; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in ibatis/moon-knowledge.xml. --- The error occurred while applying a parameter map. --- Check the com.ymkyve.moon.pojo.Knowledge.create-InlineParameterMap. --- Check the statement (update failed). --- Cause: java.sql.SQLException: Incorrect string value: '/xE4/xB8/xAD/xE8/xBD/xBC...' for column 'title' at row 1]]
欢迎大家阅读《mysql字符集设置遇到的有关问题》,跪求各位点评,by 搞代码
一看提示明显是character set的设置问题,由于alter它的默认character set为utf8
ALTER SCHEMA `moon` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci ;
再次用test case去insert,还是报错
网上查来查去,解决办法无非就是改字符集设置,咋个不行呢
后来看到一哥们说,schema的设置是改了,但表的设置仍然是默认的,于是乎使用强大的workbench再去改表的character set
执行,还是没效果
无奈之下,drop schema 重新执行了建表脚本,行了………..
具体原因有待研究.