File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CachedRowSet

 
Richard Mendoza
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a cachedrowset to store data from the database... I wanted to sort the data in the cachedrowset by a particular field. Say I have queried the data resulting to 10 columns and eventually stored in a cachedrowset. I wanted to sort it for example by column 1 or column 3 or any column without reconnecting again to the database.
How am I going to do that?



Thanks,


Richard
 
damien malone
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you will have to parse out the results into memory, either into VO's that corresponds to the objects being brought back, or maybe even something as simple as a arraylists, a new instance for each row. You can then run a sorting algorithm on these, and store in something like a sorted list.

Damien
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree that it is good to use an ArrayList of value objects (beans with get and set methods.) Also, keep in mind that Java has a sort method. So all you have to do is write a Comparator that sorts on the correct field number and call Collections.sort(). It's much easier than writing your own sort algorithm.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic