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

Java4s_Author
Sivateja Kandula - 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

3 Responses to “About update( dynamic sql ) Method Of Spring JdbcTemplate Class”
  1. sridhar says:

    hi..

    I am having some confusion here at execute()&update()…

    I want to know the difference between select and non-select operations

  2. kalyan says:

    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)

  3. Hakim says:

    This site is too good!!!
    My lots of confusion is clear of this site…

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 - 2024 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.