郁闷,jsp中从mysql有条件查询数据居然出错!!!!!!!!!!!!!
郁闷,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 '='"
请看看什么错误?????????????????????
代码如下:
/*
*对数据库操作函数(从数据库中查询记录)
*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 '='"
请看看什么错误?????????????????????
...全文
相关推荐
jsp实现按条件查询
在jsp中实现按条件查询的技术,这是我自己搜的,跟大家分享一下
jsp+MYSQL编写的按条件查询代码
本资源可以实现JSP数据库的链接 可以实现按条件查询数据库
JSP的数据库MySQL查询,插入,删除,修改操作
JSP的数据库MySQL查询,插入,删除,修改操作
Jsp连接MySql,实现对数据的增删改查
用Jsp页面连接MySql数据库,实现对数据的增删改查。包含jsp源文件,java源文件,sql源文件,以及配置文件。可以直接导入myeclipse。
使用servlet,jdbc将mysql中数据显示在jsp页面中
使用servlet,jdbc将mysql中数据显示在jsp页面中


Web 开发
