Get all updates of Java4s
Follow Us: Email 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..


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 Author ♦

Full Stack( Java/J2EE & UI/UX ) Developer and founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog. Sign-up for the Email Newsletter for your daily dose of Java tutorials.


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.


By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Hibernate spring struts Servlets ajax Log4j jQuery Json Core Java Web Services AngularJs
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Useful Links Current & UpComing Tutorials
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

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