Executing DDL statements by R4R Team

Executing DDL statements :-

Executing an SQL statement requires very little code. You need a DataSource and a JdbcTemplate, including the convenience methods that are provided with the JdbcTemplate.
We can use the execute(..) method from jdbcTemplate to execute any SQL statements or DDL statements. Following is an example to use CREATE statement to create a table:

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;

public class ExecuteStatement {

private JdbcTemplate jt;

public void setDataSource(DataSource ds) {

this.jt = new JdbcTemplate(ds);}

public void Execute() {

this.jt.execute("create table Employee (id integer, name varchar(20),salary integer)");

}}

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!