您的位置:首页 > 编程语言 > Java开发

java.sql.SQLException: Illegal mix of collations (gb2312_chinese_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '=

2010-06-09 11:19 696 查看
java.sql.SQLException: Illegal mix of collations (gb2312_chinese_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '='
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
 at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1120)
 at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:675)
 at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1027)
 at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
 at com.ericliu.DAO.UserManagerDAO.validateProductUser(UserManagerDAO.java:233)
 at com.ericliu.service.UserValidateService.validateLogIn(UserValidateService.java:52)
 at com.ericliu.service.UserValidateService.main(UserValidateService.java:69)

 

恶心的错误;

解决方法:

1、词序集错误----修改数据库中表中相应字段的词序一致

 

2、用introducer指定文本字符串的字符集:

– 格式为:[_charset] 'string' [COLLATE collation]

比如"select * from productuser p where p.username = ? and p.password = ?";

修改为:

"select * from productuser p where p.username = _utf8 ? COLLATE utf8_general_ci  and p.password = _utf8 ? COLLATE utf8_general_ci ";

 

Got it!

FK!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  collation string 数据库
相关文章推荐