错误原因:mysql执行语句出错。
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 '? and password = ?' at line 1
出错代码:
String sql = "select * from users where username = ? and password = ?";
ps = conn.prepareStatement(sql);
ps.setString(1, u.getUserName());
ps.setString(2, u.getPassWord());
rs = ps.executeQuery(sql);
出错原因:
查看帮助文档中的PreparedStatement类中的executeQuery方法描述
-
ResultSet
executeQuery()
执行此
PreparedStatement
对象中的SQL查询,并返回查询生成的ResultSet
对象。