Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

preferred collection class for storing Resultset?

 
Bala Krishniah
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is the preferred collection class to use for storing database ResultSets?
I have multiple columns in the result set, and I combine them into their own data structure for each row. Which is the best Collection class to store the objects??
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bala Krishniah:
Which is the preferred collection class to use for storing database ResultSets?
I have multiple columns in the result set, and I combine them into their own data structure for each row. Which is the best Collection class to store the objects??

I've always found ArrayLists to be sufficient ( better than Vectors ).
 
sarah Marsh
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why ArrayLists is better than Vectors ?
Thanks a lot.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, ArrayList & Vector are pretty much the same besides the fact that the methods in the vector class are synchronized. If you don't need synchronization, then use an ArrayList.
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used CachedRowSet which is like resultset but remains alive after closing the connection. After that I sometimes make a bespoke bean for the data object and instantiate it in an array big enough (from .size() of the CachedRowSet)

Adam
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!