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

Java4s_Author
sivateja@java4s.com
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.

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.
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
Upcoming
  Web Services [ SOAP ], JSP
Contact | About Us | Privacy Policy | Advertise With Us

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