本帖最后由 lijiao7073 于 2010-03-30 11:48:23 编辑

解决方案 »

  1.   

    就是你转换的iso-8859-1 不能输入中文。换成UTF-8就好了!
      

  2.   

    最好要统一页面和数据库的字符编码
    以减少浪费因字符原因出现bug的时间
      

  3.   

    PreparedStatement s = conn.prepareStatement("select * from users where userName=? and password=?");
    s.setString(1, ...)
    s.setString(2, ...)
    ResultSet rs = s.executeQuery();
      

  4.   


    String condition="select * from users where userName='"+logname+"' and password='"+password+"'" ;
    sql=con.createStatement();
    ResultSet rs=sql.executeQuery(condition); //好像就是这里出问题了。
    主要还是loginName乱码了,转码就没有问题。
    建议编码统一utf-8
      

  5.   

    OK了。把
    logname=handleString(logname);
    password=handleString(password);
    注释掉就可以了或者放到执行SQL语句代码的后边。大概是在执行SQL语句时,已经自动把SQL语句重新编码了吧
    而加上上面两行的代码,相当于编码了两次,所以出错了。猜测是这样的....