在向数据库查询时,传入的中文变成乱码,求解决方案 ps=conn.prepareStatement("select * from user where pwd=?,nickname=?"); ps.setString(1, pwd); ps.setString(2, nickname); pwd 是英文,nickname是中文,每次查找的时候都提示You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' nickname = '???????‘?'' at line 1 这个问题,向数据库插入的时候就没有问题,不是为什么查找就不行,知道的大神帮下忙啊!
------解决方案-------------------- 晕,你的SQL语句写错了,应该是select * from user where pwd=? and nickname=?
------解决方案-------------------- Connection con=DriverManager.getConnection(conURL); Statement s=con.createStatement(); ResultSet rs=s.executeQuery("select *from vip"); int i=0; while(rs.next()) {