当前位置: 移动技术网 > IT编程>数据库>Mysql > MySql 错误Incorrect string value for column

MySql 错误Incorrect string value for column

2017年12月12日  | 移动技术网IT编程  | 我要评论
使用javabean出现以下错误,

66480555 [http-80-4] warn org.hibernate.util.jdbcexceptionreporter - sql error: 1366, sqlstate: hy000
66480555 [http-80-4] error org.hibernate.util.jdbcexceptionreporter - incorrect string value: '\xe7\x89\xa9\xe8\xb5\x84...' for column 'search' at row 1
org.hibernate.exception.genericjdbcexception: could not execute query
at org.hibernate.exception.sqlstateconverter.handlednonspecificexception(sqlstateconverter.java:103)
at org.hibernate.exception.sqlstateconverter.convert(sqlstateconverter.java:91)
at org.hibernate.exception.jdbcexceptionhelper.convert(jdbcexceptionhelper.java:43)
at org.hibernate.loader.loader.dolist(loader.java:2208)
at org.hibernate.loader.loader.listignorequerycache(loader.java:2102)
at org.hibernate.loader.loader.list(loader.java:2097)
at org.hibernate.loader.custom.customloader.list(customloader.java:289)
at org.hibernate.impl.sessionimpl.listcustomquery(sessionimpl.java:1699)
at org.hibernate.impl.abstractsessionimpl.list(abstractsessionimpl.java:142)
at org.hibernate.impl.sqlqueryimpl.list(sqlqueryimpl.java:152)
at ceapet.jbpm.fileuploadbean.mrecordslist(fileuploadbean.java:313)

java.sql.sqlexception: incorrect string value: '\xe4\xba\x8c\xe6\xac\xa1...' for column 'search' at row 1

不能使用中文进行搜索,但是insert into 中文是可以的。我的数据库和数据表中所有的charset都是设置的utf8。
我在windows xp下程序没有问题,但是在linux下,同样的程序、同样的数据库就报错,百思不得其解。

网上搜了搜有很多关于此的问题,当然基本都是insert into 报错,基本都是建议set names gbk,或是把数据库删掉重新建。

但针对我的具体情况,应该不是上述原因。仔细考虑后,我的这个sql执行的是存储过程,是不是存储过程也应该和表一样有字符集的问题,果然,
存储过程的参数的字符集也应该设置。
复制代码 代码如下:

create definer=`root`@`localhost` procedure `ceapet_upload_proce`(in userid varchar(30),in dir varchar(30),in search varchar(30) charset utf8)

问题就这样解决了!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网