public static void add(String username_, String password)
{
try {
conn = DBConnection.getConnection();
String sql = "insert into userinfo (uid, user, password) values (null,'?','?')";
pstm = conn.prepareStatement(sql);
pstm.setString(2,username_);
pstm.setString(3,password);
pstm.executeUpdate();
System.out.println("数据添加成功");
}catch (SQLException e) {
e.printStackTrace();
}
}
}
pstm.setString(2,username_);
pstm.setString(3,password);
``
java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 0).
为什么错?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…