• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

update a row using spring jdbctemplate

 
Greenhorn
Posts: 14
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
soumya dash
Greenhorn
Posts: 14
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
soumya dash
Greenhorn
Posts: 14
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!