wood burning stoves 2.0
The moose likes JDBC and Relational Databases and the fly likes I try to get whole row from database but... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "I try to get whole row from database but..." Watch "I try to get whole row from database but..." New topic

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

Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Dear Friends,
I try to get whole row but I guess it returns just the last row!!!
Could you please help me?
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();
ctx.put("name", xobj );

Col Bell

Joined: Mar 21, 2002
Posts: 12
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

Col<br /><a href="http://www.squirrelsql.org" target="_blank" rel="nofollow">http://www.squirrelsql.org</a>
Don't get me started about those stupid light bulbs.
subject: I try to get whole row from database but...