public boolean checkUser(String u,String p){
boolean b=false;
try {
String sql="select passwd from users where username='"+u+"'";
ct=new ConnDB().getConn();
sm=ct.createStatement();
rs=sm.executeQuery(sql);
System.out.println(sql);
if(rs.next()){
if(rs.getString(1).equals(p)){
b=true;
}
}
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}finally{
this.close();
}
return b;
}
当u为中文名时,rs的返回结果为假
boolean b=false;
try {
String sql="select passwd from users where username='"+u+"'";
ct=new ConnDB().getConn();
sm=ct.createStatement();
rs=sm.executeQuery(sql);
System.out.println(sql);
if(rs.next()){
if(rs.getString(1).equals(p)){
b=true;
}
}
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}finally{
this.close();
}
return b;
}
当u为中文名时,rs的返回结果为假
SELECT * FROM v_$sqlarea WHERE sql_text LIKE 'select passwd from users where username%'
我是刚学jsp,连的oracle数据库,在plsql中能查询含中文的记录,但在jsp的java类中不能返回结果
SELECT sql_text FROM v_$sqlarea WHERE sql_text LIKE 'select passwd from users where username%'
select passwd from users where username='???'
select passwd from users where username='fff'
select passwd from users where username='guo'
select passwd from users where username='li'
select passwd from users where username='xiaoming'
select passwd from users where username='?ù???÷'
select passwd from users where username='郭'
'郭 '里有空格,是对的吗?
select passwd from users where username='???'
select passwd from users where username='?ù???÷'
'?ù???÷'和'???'本来是什么?
看下是不是代码有问题呢?
select * from users where username='xiaoming' 时能正确的返回
搞不好是这里比较不对造成的呢if rs.getString(1).equals(p)
System.out.println("here");
if(rs.getString(1).equals(p)){
b=true;
}
}
问题是根本就打不出here!!!!
方法:1.先在java类里进行转码new String(u.getBytes("iso-8859-1"),"gbk");
2.配置servlet.xml文件,修改tomcat/conf/server.xml,在<connector port="8080" ....>改成
<connector port="8080" .... URIEncoding="GBK"/>