Reputation: 9
this is an example:
public int addEmplyee(int id) {
return jdbcTemplate.update(
"INSERT INTO EMPLOYEE VALUES (?, ?, ?, ?)", id, "Bill", "Gates", "USA");
}
If instead of passing id
, "Bill"
, "Gates"
and "USA"
as a parameter, I want to store them in a list and want to pass it that way, how can I do it?
Upvotes: 0
Views: 980
Reputation: 691635
update()
takes a vararg (Object...
) as argument. This is just syntactic sugar for an array. So you can just pass an array as argument:
return jdbcTemplate.update(
"INSERT INTO EMPLOYEE VALUES (?, ?, ?, ?)", new Object[] {id, "Bill", "Gates", "USA"});
If you jave a List, then simply transform it to an array.
Upvotes: 1