File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring updates more than one row

 
Booma Devi
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • 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...

 
Ashwin Sridhar
Ranch Hand
Posts: 272
Flex Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is this method ?
 
Booma Devi
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • 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: 272
Flex Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could some details on this link. Doc
 
Booma Devi
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic