Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

reading data from a resultset onto a hashmap

807589Jul 27 2008 — edited Jul 27 2008
I am trying to read some data from mysql database using a jdbc resultset, this data should then be pushed onto a hashmap. All the database connections are set up correctlly and I can pass the query successfully and receive a valid resultset rs. The problem comes in when I try to store the data onto a hashmap.
  HashMap hm = new HashMap();
  
while (rs.next()){
   Object firstname = rs.getString("firstname");
   Object surname = rs.getSring("surname");
   hm.put(firstname,surname);
The hashmap does not dereference the given var and instead stores them as is "firstname","surname" .Can you help?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 24 2008
Added on Jul 27 2008
4 comments
582 views