java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
privateintcheck(Stringuser_name,Stringuser_code)throwsSQLException{//TODOAuto-generat...
private int check(String user_name, String user_code) throws SQLException {
// TODO Auto-generated method stub
PreparedStatement stmt = null;
String sql ="select * from log where name='?' and code='?';";
stmt = Server.con.prepareStatement(sql);
stmt.setString(1,user_name);
stmt.setString(2, user_code);
if(stmt.executeQuery(sql)==null){
return 0;
}
return 1;
}
大神求救啊!!!!!!!!!!!!! 展开
// TODO Auto-generated method stub
PreparedStatement stmt = null;
String sql ="select * from log where name='?' and code='?';";
stmt = Server.con.prepareStatement(sql);
stmt.setString(1,user_name);
stmt.setString(2, user_code);
if(stmt.executeQuery(sql)==null){
return 0;
}
return 1;
}
大神求救啊!!!!!!!!!!!!! 展开
1个回答
展开全部
String sql ="select * from log where name='?' and code='?';";改成
String sql ="select * from log where name=? and code=?“;
String sql ="select * from log where name=? and code=?“;
追问
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 code=?' at line 1
追答
String sql ="select * from log where name=? and code=?";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询