郁闷,jsp中从mysql有条件查询数据居然出错!!!!!!!!!!!!!

yong427 2004-09-22 02:07:57
郁闷,jsp中从mysql有条件查询数据居然出错!!!!!!!!!!!!!
代码如下:
/*
*对数据库操作函数(从数据库中查询记录)
*String--strSql:传入的SQL语句
*ResultSet--return:返回查询的ResultSet值
*/
public ResultSet OpeSqlRst(String strSql) throws SQLException,Exception{
ResultSet sqlRst;
try{
//Statement对象
sqlStmt = con.createStatement();
sqlRst = sqlStmt.executeQuery(strSql);
}catch(SQLException sen){
strError = sen.getMessage();
throw new SQLException(strError);
}catch(Exception en){
strError = en.getMessage();
throw new Exception(strError);
}
return sqlRst;
}
///////////////////////////////
如果strSql="select count(*) from user"则没有错误
//////////////////////////////
如果strSql="select count(*) from user where us_name='admin' and us_pwd='admin'"
则出现下列错误:
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: General error message from server: "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (gb2312_chinese_ci,COERCIBLE) for operation '='"
请看看什么错误?????????????????????

...全文
69 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yong427 2004-09-22
  • 打赏
  • 举报
回复
你前后的连接没有正确的设置编码方式
my.ini中:
[mysqld]
default-character-set=gbk

[client]
default-character-set=gbk


连接字符串需要useUnicode=true和gb2312才行
//////////////////////////
我已经设置了呀,我的连接字符串是:
String strCon = "jdbc:mysql://localhost:3306/myguest?useUnicode=true&characterEncoding=gb2312";
ChDw 2004-09-22
  • 打赏
  • 举报
回复
你前后的连接没有正确的设置编码方式
my.ini中:
[mysqld]
default-character-set=gbk

[client]
default-character-set=gbk


连接字符串需要useUnicode=true和gb2312才行

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧