Updating the database by R4R Team

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);

}}

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!