jQuery in Action, 2nd edition
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 » Databases » 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>
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: I try to get whole row from database but...
 
Similar Threads
Please help....confused:
How can I call my obj in another program?
number of rows Resultset ???
Please help...
How can I solve IllegalArgumentException