This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Is there a utility class that will hold a table with multiple columns/fields? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Is there a utility class that will hold a table with multiple columns/fields?" Watch "Is there a utility class that will hold a table with multiple columns/fields?" New topic
Author

Is there a utility class that will hold a table with multiple columns/fields?

Chris Garrison
Ranch Hand

Joined: Jun 13, 2002
Posts: 44
I'm looking for a utility class (Vector, hashtable, etc.)that will hold a table, thus preventing repeated database/sql calls.
For instance - an ingredients table that holds names, prices, descriptions , dates, etc.
MysteryClass ingredients = new MysteryClass();
ingredients.add("salt", new Double(.65), "Mortens" ...);
ingredients.add("sugar", new Double (1.10), "Kroger Brand" ...);
ingredients.add("baking powder", new Double(2.50), "Arm & Hammer" ...);
and so on and so forth???
Im sure there's a way -however, it escapes me.
[ November 13, 2002: Message edited by: Chris Garrison11 ]
[ November 13, 2002: Message edited by: Chris Garrison11 ]

May the force be with you, always.
Chandresh Patel
Greenhorn

Joined: Jul 05, 2002
Posts: 14
You can use a ArrayList of HashMap objects. In which case ingrediants will be an ArrayList object and values like "salt", new Double(.65), "Mortens" ... should be in HashMap, ofcourse keyed by some identifier.
Or you can hava ArrayList of ArrayList. In which case internal values will be in particular order all the time.
Or you can have ArrayList of Ingrediant value object. You will have to create a Ingrediant object with all the attributes required.


Chandresh
 
Consider Paul's rocket mass heater.
 
subject: Is there a utility class that will hold a table with multiple columns/fields?
 
Similar Threads
A good HTML editor/Web page designer (software)
What's the diff b/tw a Session EJB and a regular java bean used w/ JSPs?
Googlism!
Inheritance Hierarchy??
NumberFormatException