Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8390777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:05:37+00:00 2026-06-09T19:05:37+00:00

I am new to spring. I am developing a CRUD application using spring jdbc

  • 0

I am new to spring. I am developing a CRUD application using spring jdbc template. I am done with insert and select. but in update am facing some problem. can anybody provide me a simple example of update and delete using jdbctemplate.
thnks in advance.

MY CONTROLLER-

@RequestMapping(method = RequestMethod.GET)
    public String showUserForm(@ModelAttribute(value="userview")  User user,ModelMap model)
    {
        List list=userService.companylist();
        model.addAttribute("list",list);
        return "viewCompany";
    }

@RequestMapping( method = RequestMethod.POST)
public String add(@ModelAttribute(value="userview") @Valid User user, BindingResult result) 
{
    userValidator.validate(user, result);
    if (result.hasErrors()) {
        return "viewCompany";
    } else {
        userService.updateCompany(user);
        System.out.println("value updated");
        return "updateSuccess";
    }

when i click on update button the edited values should be updated in my DB according to the row ID , my problem is how to map the row id from jsp to controller.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:05:39+00:00Added an answer on June 9, 2026 at 7:05 pm

    Straight from the documentation:

    The following example shows a column updated for a certain primary
    key. In this example, an SQL statement has placeholders for row
    parameters. The parameter values can be passed in as varargs or
    alternatively as an array of objects. Thus primitives should be
    wrapped in the primitive wrapper classes explicitly or using
    auto-boxing.

    import javax.sql.DataSource;
    
    import org.springframework.jdbc.core.JdbcTemplate;
    
    public class ExecuteAnUpdate {
    
        private JdbcTemplate jdbcTemplate;
    
        public void setDataSource(DataSource dataSource) {
            this.jdbcTemplate = new JdbcTemplate(dataSource);
        }
    
        public void setName(int id, String name) {
            this.jdbcTemplate.update(
                    "update mytable set name = ? where id = ?", 
                    name, id);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Spring and AOP in Java (though I've done some related stuff
I am developing a web application using Spring JS and Dojo Toolkit. In this
I am using Spring Web MVC and Hibernate for developing my application. My login.jsp
I am using Spring, Hibernate for developing my application. And as DB side, I
I am developing a new web application with Struts2, Spring and Hibernate as its
I am developing my application using spring-web-mvc... Now at my Controller it returns like
I am developing a small utility application emailafriend using Spring. The basic functionality is
I'm developing using IntelliJ 11u on a spring mvc application using tomcat. I tried
I'm new to android developing but right now I'm working on an application that
I am new to Spring and developing a dynamic web application in Spring and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.