总是出现这个异常java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
首先我是写
public int executeUpdate(String sql, String[] values) throws Exception {
ps = con.prepareStatement(sql);
if (values != null) {
for (int i = 0; i < values.length; i++) {
ps.setString(i + 1, values[i]);
}
}
return ps.executeUpdate();
}
然后调用这个方法
public ResultSet checkJufab(int j,String XM)
{
inf[0]=XM;
sqlword="select * from jhfab where BZ= ?";
try {
rs = db.executeQuery(sqlword, inf);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(inf[0]);
return rs;
}