aspose file tools*
The moose likes Spring and the fly likes update a row using spring jdbctemplate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "update a row using spring jdbctemplate" Watch "update a row using spring jdbctemplate" New topic
Author

update a row using spring jdbctemplate

soumya dash
Greenhorn

Joined: Jul 17, 2012
Posts: 14

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.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1666
    
    7

Insert update and delete all use the same syntax



Where the Query can be any insert, update or delete SQL statement and the objects param1 and param2 correspond to the 2 ?'s in the query that was passed in.


[How To Ask Questions][Read before you PM me]
soumya dash
Greenhorn

Joined: Jul 17, 2012
Posts: 14

thnks.

but how to get the param value from JSP? the values to be passed from jsp to controller so that service class can implement the method with the param passed.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17256
    
    6

soumya dash wrote:thnks.

but how to get the param value from JSP? the values to be passed from jsp to controller so that service class can implement the method with the param passed.


How are you getting it for the insert? Update would be the exact same. If you have a form for insert, you would want to use it for update too.

For delete you would probably only need the id/primary key value from the page.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
soumya dash
Greenhorn

Joined: Jul 17, 2012
Posts: 14

for insert, the pojo obj is mapped. but for update you need to map the Id of that particular row as in delete.. that's what i'm asking how to map that id by submit button.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1666
    
    7

Store the objects id as a hidden field on your JSP in the same fashion that you do with the other fields. If it is null when it comes in on your controller than you know to do an insert, otherwise you will update.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: update a row using spring jdbctemplate