Updating the database:-
The following example shows a column updated for a primary key. In this example,
an SQL statement has placeholders for row parameters. The parameter values can
be passed in as varargs or alternatively as an array of objects. Thus primitives
should be wrapped in the primitive wrapper classes explicitly or using
auto-boxing.
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;
public class ExecuteUpdate {
private JdbcTemplate jt;
public void setDataSource(DataSource ds) {
this.jt = new JdbcTemplate(ds); }
public void setName(int id, String name) {
this.jt.update("update Employee set name = ? where id = ?", name, id);
}}