java.sql.SQLException:Parameter index out of range (1 > number of parameters,which is 0).
private int check(String user_name,String user_code) throws SQLException {
\x05\x05// TODO Auto-generated method stub
\x05\x05PreparedStatement stmt = null;
\x05String sql ="select * from log where name='?' and code='?';";
\x05stmt = Server.con.prepareStatement(sql);
\x05stmt.setString(1,user_name);
\x05stmt.setString(2,user_code);
\x05if(stmt.executeQuery(sql)==null){
\x05\x05return 0;
\x05}
\x05 return 1;
\x05}
人气:151 ℃ 时间:2020-05-30 15:06:39
解答
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 1String sql ="select * fromlog where name=? and code=?";
推荐
猜你喜欢
- He is ( )than me.1、tall 2、taller 3、tallest.选择理由
- 甲、乙两桶纯净水,甲桶有28kg水,若甲桶喝掉了四分之一,乙桶喝掉了五分之二后,剩下的水一样重.乙桶原有水多少千克?(带算式)
- 根号3分之3-(根号3)的2次方+(π+根号3)的0次方-根号27+|根号3-2
- 人生的路上有无数条轨道可走,之所以选择了其中一条,是偶然,更是必然.
- 一棵大树的影子长3.5米同时同地又测了一根竹竿影子长50分米问这棵大树有多高
- 脱式计算,能简算的要简便.
- Who can tell me what place it is 还是Who can tell me what place is it?
- a剪b等于2,a减c等于1,则〔2a减b减c〕的平方加〔c减a〕的平方等于