Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I try to get whole row from database but...

 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,
I try to get whole row but I guess it returns just the last row!!!
Could you please help me?
Thanks,
Elahe
------------
rs =stmt.executeQuery("select s.text,b.bugNumber,b.bdesc,b.submittedDate,b.contact,u.name from bug b, user u, statusDesc s where b.ID=s.ID and b.userId=u.userId and s.text='open'");

/* walk the ResultSet and populate the vector with rows of objects */
ResultSetMetaData rsmd = rs.getMetaData();

while (rs.next()) {
C_BugList xobj=new C_BugList();
xobj.setStatus(rs.getString("text"));
xobj.setBugNumber(rs.getInt("bugNumber"));
xobj.setBdesc(rs.getString("bdesc"));
xobj.setSubmittedDate(rs.getString("submittedDate"));
xobj.setContact(rs.getString("contact"));
xobj.setName(rs.getString("name"));
ctx.put("name", xobj );
}
 
Col Bell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is probably your problem

You create a new instance of your BugList object and store it in the collection using the key "name". Because you keep using the same key you will just store the last object. See Map.put(...) in the JDK JavaDoc.
You probably want to do something like
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic