You are making a mess by creating the variable name dynamically by appending the counter as a String
literal (Event1
) and setting them to the prepared statement as a String
input. You are actually setting the String
literals like (Event1
) instead of Values (22122014 13.26
). This is not the way you should do.You may have to set the values directly like
prepState.setString(1, Event1);
prepState.setString(2, Event2);
prepState.setString(3, Event3);
prepState.setString(4, Event4);
I'd suggest you to go for a List of String literals having all the Event values. Iterate them and set them in the Prepared statement and execute the query.
List<String> eventValues = new ArrayList<String>();