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 .::

Java4s_Author
- Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

2 Responses to “About execute(sql) Method Of Spring JdbcTemplate Class”
  1. tanvir says:

    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

  2. Anisha says:

    select is a DML command, not a DDL command.

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2018 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.