String sql = "select * from users where readername='"+name+"'"+"and where pa 5
Stringname=u.getName();Stringpassword=u.getPassword();Stringsql="select*fromuserswher...
String name = u.getName();
String password = u.getPassword();
String sql = "select * from users where readername='"+name+"'"+"and where password='"+password+"'";
ResultSet rs = stmt.executeQuery(sql);
求解释这里那里错了?
2015-2-28 13:41:55 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
信息:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'where password=''' at line 1 展开
String password = u.getPassword();
String sql = "select * from users where readername='"+name+"'"+"and where password='"+password+"'";
ResultSet rs = stmt.executeQuery(sql);
求解释这里那里错了?
2015-2-28 13:41:55 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
信息:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'where password=''' at line 1 展开
1个回答
展开全部
你的语句拼错了,密码的查询前面多了一个where,应该是
String sql = "select * from users where readername='"+name+"'"+"and password='"+password+"'";
追问
我要的是条件同时成立哦,为什么我这样写
while(rs.next()){
us.setName(rs.getString("readername"));
us.setPassword(rs.getString("password"));
}
con.close();
return us;
为什么不管输入什么,us永远有值
追答
呃..你应该去看一下SQL的写法以,where就是指判断条件的开始,后面的就是多个条件的拼接,不需要再使用where一个一个去引
us一直有值?你是指这个对象还是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询