MySql 错误Incorrect string value for column

很文博客hinven.com 数据库评论277字数 1652阅读模式
广告也精彩

能使用中文进行搜索,但是insert into 中文是可以的。我的数据库和数据表中所有的charset都是设置的utf8。
使用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)文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/39608.html

java.sql.SQLException: Incorrect string value: '\xE4\xBA\x8C\xE6\xAC\xA1...' for column 'search' at row 1文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/39608.html

不能使用中文进行搜索,但是insert into 中文是可以的。我的数据库和数据表中所有的charset都是设置的utf8。
我在Windows xp下程序没有问题,但是在Linux下,同样的程序、同样的数据库就报错,百思不得其解。文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/39608.html

网上搜了搜有很多关于此的问题,当然基本都是insert into 报错,基本都是建议set names gbk,或是把数据库删掉重新建。文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/39608.html

但针对我的具体情况,应该不是上述原因。仔细考虑后,我的这个sql执行的是存储过程,是不是存储过程也应该和表一样有字符集的问题,果然,
存储过程的参数的字符集也应该设置。文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/39608.html

  1. CREATE DEFINER=`root`@`localhost` PROCEDURE `ceapet_upload_proce`(IN userId varchar(30),IN dir varchar(30),IN search varchar(30) charset utf8)

问题就这样解决了!文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/39608.html 文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/39608.html

工具:作品在线观看

女优:最新作品观看

中文:国语在线观看

weinxin
我的微信
扫一扫更精彩
大家的支持是我更新的动力!!!
 
广告也精彩
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证