Explain how the update method in JdbcTemplate can be used to perform insert, update and delete operations.
Answered
Explain how the update method in JdbcTemplate can be used to perform insert, update and delete operations.
Best answer
The update() method in JdbcTemplate can be used to perform insert, update and delete operations as shown below:
- Insert Operation
this.jdbcTemplate.update("insert into employee (empid, empname) values (?, ?)", 1000L, "James");
- Update Operation
this.jdbcTemplate.update("update employee set empname = ? where empid = ?", "Jeff", 1000L);
- Delete Operation
this.jdbcTemplate.update("delete from employee where empid = ?", Long.valueOf(empId));