• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring updates more than one row

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi

Can anyone please help me how to update more than one rows using JdbcTemplate


I have query like this


UPDATE EMPLOYEE SET STATUS='REGISTERED' WHERE EMP_ID IN (:empids)


I want to update the status as registered for the employee ids...


How can we achieve this in spring...

 
Ranch Hand
Posts: 277
Oracle Spring Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is this method ?
 
Booma Devi
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Method used to execute the query..

I want to pass the list of employee ids and status.. FOr this I need 2 parameters. so inside the method, i declared 2 parameters.

I want to know how to execute the query using NamedParameterJdbcTemplate. I found one example below

But this query for select all the ids from the table. But i want to update the status for all the employee ids.
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Oracle Spring Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could some details on this link. Doc
 
Booma Devi
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to update the employee status as "Registered"

for the list of employee ids.. I tried with the below

code.. But update command gets hanged..

Can anyone please help me to complete this..


From Servlet I passed the List of values to the

updateEmployeeStatus:

ArrayList<String> empidList =new ArrayList<String>();

empidList.add("1");
empidList.add("2");
empidList.add("3");

Method in Employee Status class:
--------------------------------

public boolean updateEmployeeStatus(List<String> empIdlist)
{

String query="UPDATE EMPLOYEE SET STATUS='Registered'
WHERE EMP_ID IN(:empids);

Employee e=new Employee();

e.setEmpIDList(empIdlist);

Map<String,Object> params=new HahMap<String,Object>();

params.put("empids",e.getEmpIDList); ------------> Passing employee ids to the IN clause...

int count=getNamedParameterJdbcTemplate().update
(query,params); ----------> gets hanged..

}
 
Booma Devi
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem solved...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic