The moose likes JDBC and the fly likes I try to get whole row from database but... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JDBC
Reply Bookmark "I try to get whole row from database but..." Watch "I try to get whole row from database but..." New topic
Author

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?
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 );
}


Thanks,
Elahe
Col Bell
Greenhorn

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>
 
 
subject: I try to get whole row from database but...
 
Threads others viewed
Please help...
How can I call my obj in another program?
number of rows Resultset ???
Please help....confused:
How can I solve IllegalArgumentException
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture