• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help needed with ResultSet

 
Praveen Dharmavaram
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get a resultset from SQL Query which looks like

FirstNameLastNameUseridphonephone_seqdefaultphonetype
------------------------------------------------------
bobdole100234567890101ent
bobdole100234567890211ent
johnsmith101234567890303per
johnsmith101234567890413per
johnsmith101234567890523per
johnsmith101234567890633per


I want to know if there is an easy of parsing this resultset andput them into hashmaps

hashmap1
--------
Firstname=bob
Lastname=dole
userid=100
phone1=2345678901
phone2=2345678902
default_phone=1
type=ent

hashmap2
--------
Firstname=john
Lastname=smith
userid=101
phone1=2345678903
phone2=2345678904
phone3=2345678905
phone4=2345678906
default_phone=3
type=per


Any help is appreciated.

Thanks

[Bear edit: adjusted title]
[ April 07, 2005: Message edited by: Bear Bibeault ]
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36026
430
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Praveen,
You start by looping through just like in a standard result set. The first time through, just add the name/value pairs to the map. Also store the user id (key) in a variable. On subsequent iterations of the loop, see if the user id is the same as in the previous row. If it is the same, just read the phone # and add it too the hashmap. If it is different, read all the data into a new hashmap.

Note that it isn't necessary to return phone_seq if it isn't being used. Sometimes this makes queries faster and it always makes them clearer.
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!