[英]Exception in thread “main” java.sql.SQLException: No value specified for parameter 1
[英]nested exception is java.sql.SQLException: No value specified for parameter 6
嘗試更新數據庫中的記錄時出現錯誤。 我認為嘗試通過在輸入中接受6個值來解決錯誤,但是在更新記錄時,我僅使用了5個值。 我需要使用eventId來更新特定條目的數據庫記錄。 我不想更改eventId,而只是刪除事件。 我的表按以下順序設計-eventId,eventTitle,roomId,eventInfo,startDate,endDate。 我得到的錯誤是
嵌套異常為java.sql.SQLException:未為參數6指定值
public void updateEvent(int eventId, String eventTitle, int roomId, String eventInfo, String startDate, String endDate) {
String SQL = "UPDATE Event SET eventTitle = ?, roomID = ?, eventInfo = ?, startDate = ?, endDate =? WHERE eventId = ?";
jdbcTemplateObject.update(SQL,eventTitle,roomId,eventInfo,startDate,endDate);
System.out.println("Updated Event with eventID = " + eventId );
return;
}
您在這里缺少eventId:
jdbcTemplateObject.update(SQL,eventTitle,roomId,eventInfo,startDate,endDate,eventId);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.