我在 netbeans 6.9 中使用 struts 1.3.8 框架,我想通过使用preparedStatement
. 它不断给我一个错误(没有为参数3指定值),我不知道那个参数是什么原因我通过定义id来设置一个值。我很感激你的辛勤工作,希望你能帮助我。
这是我的代码:
try{
// update the item Qyt in the item table after checking it out
PreparedStatement ps2 = (PreparedStatement) con.prepareStatement("UPDATE item SET itemQyt=? WHERE itemID=?"
+ " VALUES (?,?)");
ps2.setInt(1, newQuantity);
ps2.setInt(2, itemID);
int updateRows = ps2.executeUpdate();
ps2.close();
} catch (Exception e) {
errors.add("SQLUpdatingItem", new ActionMessage("errors.SQLUpdatingItem"));
System.out.println("ERROR Updating : Did not Update the itemQyt in the item table which the itemId is : " + itemID + " and the new Qyt is :" + newQuantity + " " + e);
}
这是错误消息:
错误更新:未更新 itemId 为 7 且新 Qyt 为:9 的 item 表中的 itemQyt java.sql.SQLException:未为参数 3 指定值