gpt4 book ai didi

java.sql.SQLException : Missing IN or OUT parameter at index, 即使我提供了正确数量的参数

转载 作者:行者123 更新时间:2023-12-01 23:00:16 24 4
gpt4 key购买 nike

当我运行以下代码时,我收到错误java.sql.SQLException:在index::3处缺少IN或OUT参数。我检查了参数,只有 2 个,而且我在 PreparedStament 中只使用了 2 个。

for (int i = 0; i < count; i++) {
JsonObject projectObject = projectQueryResponse.getResults().get(i).getAsJsonObject();
JsonObject obj = projectObject.getAsJsonObject();
//System.out.println(obj);
projectValue = getJsonValue(obj, "_refObjectName");
System.out.println(projectValue);
objectValue = getJsonValue(obj, "ObjectID");
System.out.println(objectValue);

//st.("INSERT INTO CUST_RALLY_PROJECT_OBJID Values('" + projectValue + "','" + objectValue + "')");

updateString += "update odf_ca_other ";
updateString += "set rallyid = ? ";
updateString += "where id = (select inv.id from inv_investments inv, odf_ca_other oco where inv.id = oco.id and inv.odf_object_code = 'other' and inv.name = ? ";
updateString += "AND ( oco.team_type = 'delivery_team' or oco.team_type = 'reg_team' or oco.team_type = 'ux_team' or oco.team_type = 'business_team')) ";

PreparedStatement rs = conn.prepareStatement(updateString);
rs.setString(1, objectValue);
rs.setString(2, projectValue);
rs.execute();
conn.commit();
}

最佳答案

updateString = ""; 

您必须在下一次迭代之前清空它。

否则,在循环外部定义一次,然后在循环内部重用它。正如@mark 在评论中提到的!

关于java.sql.SQLException : Missing IN or OUT parameter at index, 即使我提供了正确数量的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23470688/

24 4 0