Reputation: 115
I have a table which contains columns full_name & department.I have written a query like this
String query ="select full_name from users where department='QS'";
ps=con.prepareStatement(query);
rs=ps.executeQuery();
while(rs.next()){
joborderbean.setQs(rs.getString(1));
list.add(joborderbean);
i have two full names with the department name QS. But the list returning only one name two times.
Please help me.
Upvotes: 1
Views: 65
Reputation: 393946
Create a new object in each iteration of the loop :
while(rs.next()){
joborderbean = new WhateverClassItIs();
joborderbean.setQs(rs.getString(1));
list.add(joborderbean);
Upvotes: 5