Newsletter |
About update( dynamic sql ) Method Of Spring JdbcTemplate Class
Spring » on Feb 10, 2012 { 3 Comments } By Sivateja
Let us see few pints regarding update() method of JdbcTemplate class in spring framework
- update() method in spring JdbcTemplate class is suitable for DML [ non-select i mean insert, update, delete.. ] operation on the database
- update() method accepts either static or dynamic sql commands as parameter
Syntax
int update(” static sql command “);
int update(” dynamic sql command “, object array);
Example
int k = jt.update(” insert into table_name values(100,’java4s’) “);
—
int k = jt.update(” insert into table_name values(?,?) “, values);
Object values[] = { new Integer(100),”java4s” };
jt = object of JdbcTemplate class
So what we understood ? if we do any operations with update() method of JdbcTemplate class on the database it will returns integer value as count like how many rows got effected in the database.
But execute() method cannot 🙂 as its return type if void.
​ ​​
You Might Also Like
::. About the Author .:: | ||
Comments
3 Responses to “About update( dynamic sql ) Method Of Spring JdbcTemplate Class”
hi..
I am having some confusion here at execute()&update()…
I want to know the difference between select and non-select operations
DDL commands are used to manage database table/table-structure but DML commands are used to manage database table data..
DDL—->create, alter, drop commands
DML—->insert, update, delete commands
—> execute for DDL commands.
—> update for DML commands.
—> query for select command.(retrievable purpose)
This site is too good!!!
My lots of confusion is clear of this site…