String sql="select * from t_dept where id = ? and name = ?"; PreparedStatement ps=conn.prepareStatement(sql); ps.setInt(1,id); ps.setString(2,name); System.out.println(ps); ResultSet resultSet = ps.executeQuery(); while(resultSet.next()){ flag++; // //对应的类是自己数据对应的 User user = new User(); user.setId(resultSet.getInt(1)); user.setName(resultSet.getString(2)); System.out.println(user);
错误示范:ps.executeQuery(sql)
错误示范:ps.executeQuery(sql)
错误示范:ps.executeQuery(sql)
Mysql--->PreparedStatement 查询报错
原文:https://www.cnblogs.com/springxian/p/13734610.html