Majimbos
Majimbos

Reputation: 7

nested exception is java.sql.SQLException: No value specified for parameter 6

I am getting an error when I try to update a record in my database. I believe the error is being cased by trying to accept 6 values in input but when updating the record I am only using 5 of them. I need to use the eventId to update the database record for the specific entry. I do not want to change the eventId and would rather just delete the event. My table is designed in the following order -- eventId, eventTitle, roomId, eventInfo, startDate, endDate. The error I am getting is

nested exception is java.sql.SQLException: No value specified for parameter 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;    
}

Upvotes: 0

Views: 183

Answers (1)

m.aibin
m.aibin

Reputation: 3603

You are missing eventId here:

jdbcTemplateObject.update(SQL,eventTitle,roomId,eventInfo,startDate,endDate,eventId);

Upvotes: 2

Related Questions