gpt4 book ai didi

java.sql.SQLException : No value specified for parameter 7

转载 作者:行者123 更新时间:2023-11-30 01:44:59 25 4
gpt4 key购买 nike

这里需要一点帮助,尝试了几种方法,但对我来说没有任何效果。我不确定我是否错过了什么

代码:

String id = request.getParameter("id");
hms1 st = dao.getRecordById(Integer.parseInt(id));
String lname = request.getParameter("lname");
String fname = request.getParameter("fname");
String mname = request.getParameter("mname");
String datein = request.getParameter("datein");
String dateout = request.getParameter("dateout");
String roomtype = request.getParameter("roomtype");



String message = null;

try {
String sql = "update hms1 set lname=?, fname=?, mname=?, datein=?, dateout=?,roomtype=? where id=? "+ st.getid();
PreparedStatement statement = con.prepareStatement(sql);
statement.setString(1, lname);
statement.setString(2, fname);
statement.setString(3, mname);
statement.setString(4, datein);
statement.setString(5, dateout);
statement.setString(6, roomtype);

int row = statement.executeUpdate();
if (row > 0) {
message = "File uploaded and saved into database";
}
response);

最佳答案

您错过了 id(您的查询需要该 ID);

statement.setString(7, id);

还有这个

String sql = "update hms1 set lname=?, fname=?, mname=?, datein=?, dateout=?,roomtype=? where id=? "+ st.getid();

应该是

String sql = "update hms1 set lname=?, fname=?, mname=?, datein=?, dateout=?,roomtype=? where id=?";

关于java.sql.SQLException : No value specified for parameter 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58424880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com