• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to copy a SQL result into a Map

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a problem with copying the results of my query code, producing four columns into a nested map - Map<String, Map<String, Map<String, Map<Integer, Map<String, Integer>>>>> puthere =
new Hashtable<String, Map<String, Map<String, Map<Integer, Map<String, Integer>>>>>();
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

You are setting up a Map to contain a Map to contain a Map to contain a Map?
You are getting 4 columns, and what you probably want is to get a Map where you have the PRIMARY KEY from the table/ResultSet/whatever as the "K" in the Map, and the remainder, probably put into a class designed to hold the remaining three columns, as the "E."
[ June 22, 2008: Message edited by: Campbell Ritchie ]
 
Smiley Benson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh yes! I see what you mean.
Run a query, get the first column, store the result in a map, then use that as key to get other values in another - say class or collection, where the Primary key equals the one in map.
But the problem is one is probably gonna end up with few thousand lines to complete! but would try it though.
Thanks
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More a case of create an object to hold all the results, and use that as the "V" in your Map. Use the primary key as the "E". And it will take several milliseconds to process your thousands of lines in Java!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic