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]]

 

 

一看提示明显是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 重新执行了建表脚本,行了...........

 

具体原因有待研究.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值