aspose file tools*
The moose likes Performance and the fly likes What will be a good approach  for sorting data extracted from DataBase. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "What will be a good approach  for sorting data extracted from DataBase." Watch "What will be a good approach  for sorting data extracted from DataBase." New topic
Author

What will be a good approach for sorting data extracted from DataBase.

PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Hello Please give your suggestions .

I want to extract the records based on Employee First Name .

What will be a good approach ?


1. To write a SQL Query based on the order by clause

OR

2. Extract the elements into a TreeSet by using a Comparator .

Thanks in advance.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31074
    
232

Both are acceptable solutions. As to which is better - 'it depends.' If the SQL query is only run for this use, adding an order by is fine.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Thanks .
pradeep dewda
Greenhorn

Joined: Apr 12, 2009
Posts: 9
Ofcourse it is fine and easy to use query..
Select * from table order by cluase ASC

We get the sorted values in ResultSet.
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Yes you are right .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What will be a good approach for sorting data extracted from DataBase.