• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

mysql字符集设置遇到的有关问题

mysql 搞代码 7年前 (2018-06-05) 141次浏览 已收录 0个评论

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 重新执行了建表脚本,行了………..

 

具体原因有待研究.

 


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:mysql字符集设置遇到的有关问题

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址