0

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;    
}
1
  • Sorry I forgot to mention I am using MySQL database. Commented Apr 6, 2016 at 17:53

1 Answer 1

2

You are missing eventId here:

jdbcTemplateObject.update(SQL,eventTitle,roomId,eventInfo,startDate,endDate,eventId);
Sign up to request clarification or add additional context in comments.

2 Comments

But if I add the eventId in there will it not update the eventID too when it runs? I just need to update the event information.
I feel stupid. Yes it works, I thought it would update the eventID. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.