Newsletter |
About execute(sql) Method Of Spring JdbcTemplate Class
Spring » on Feb 10, 2012 { 2 Comments } By Sivateja
Better if we know some thing about execute(“static sql command only“) method in spring JdbcTemplate class…
- This method is used to execute both DDL [ select ] and DML[ non-select ] operations on the database
- execute() method allows only static sql commands as parameter, i mean sql command should not contain ? [ question marks, like preparedstatements 🙂 ]
- And this method is suitable to perform DDL[ select ] operations on the database, because for DML[ non-select ] operations this method doesn’t return the count value to the programmer, else we can use this method for any DML/DDL operations. Let me clear this..
Example
jt.execute(“insert into table_name values(100,’java4s’)”);
jt = object of JdbcTemplate
See this, execute() method will executes the command and it wont returns any value back, i mean how many rows inserted/deleted bla bla, as execute() method return type is void. But in case of update() method this will returns the int value [ like how many rows got effected in database, see next session]
​ ​​
You Might Also Like
::. About the Author .:: | ||
Comments
2 Responses to “About execute(sql) Method Of Spring JdbcTemplate Class”
hi,this is tanvir pathan.I am working on a simple project on which i had to add a service on it.I dont know what is service in spring and how to add service to the spring.where to write service.I am beginner…
please help me
select is a DML command, not a DDL command.