• 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

RecordSet Vs. Hash table

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have to display some values from the database in my JSP. I'm looping on my RecordSet to dispaly the values. My manager is suggesting to transfer the records in a hash table and iterate on that and show the value, he says that it's a better way to do it , though he doesn't know the why ?
Does anybody has any idea on this.
Thanks
Neha
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you are the Java developer, and not your manager, explain to your mgr. why using a hashtable does not really buy you any thing. Unless he has a specific reason for wanting you to put it in a Hashtable(not even an ArrayList!). Loop through the resultset and do your thing!

Bosun
 
Neha Sharma
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bosun Bello,
Thanks for your reply, you know that some people have to prove they are smarter, though for no reasons. Here's the same kind of stuff with my manager.
Suggestions please regarding resultset VS. Hashtable
Bye
Neha

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well...lemme think of a few pointers to offset the hashtable paradigm..in no particular order,
1. If the resultset returns too many results, there will be a memory constraint leading to automatic hashtable rehashing, which degrades performance.
2.Unlike the new collections framework, access to hashtables are synchronized. What this means is, if you are using EJB framework then all the objects that are contained in hashtable have to be serializable.
3.If the resultset has int datatype you will have to create an Integer out of the int,every time u put or retrieve something from the Hashtable.
Since object creation is a costly process, any manager would agree to avoid this Integer object creation just for the purpose of putting things into the HashTable(Although there are workarounds to this by extending Hashtable class).

4.On the presentation front(JSP), while iterating thru the objects from the hashtable, you need to check whether an object is present thru .containsKey method to prevent java.lang.NullPointer exceptions..thereby adding to the load. Also one has to make sure that no null objects get added into the Hashtable(results again in the infamous Null Pointer exception).
Hope this gives u some moolah to be smarter
chz,
mpr
 
Neha Sharma
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you looks like a real java Guru.
Thanks Reddy Garoo
 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also with using a Hashtable you will most likely lose any "ordering" of the data contained in the record set.
ie. when you are re-iterating back through the Hashtable, it will not necessarily be in the same order that you "put" the data.
 
Neha Sharma
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Swan.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic