aspose file tools
The moose likes JDBC and the fly likes Sort a ResultSet based on data in one of the ResultSet Columns Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

Sort a ResultSet based on data in one of the ResultSet Columns

Dar Var
Ranch Hand

Joined: Oct 12, 2004
Posts: 74
Hi,

Does anyone know how the sort a ResultSet based on data in one of the ResultSet Columns?

NOTE: I do not want to run a modified query to do the sorting.

The ResultSet may contain a text column. I need to resort the ResultSet alphabetically based on this text column.

The resulting ResultSet should return for example:
Row Text Column
1 aaaa
2 bbbb
3 cccc
etc...
D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 471
Which database? I'd suggest to use temporary sorted array to insert all records from ResultSet in sorted order. This approach can be more portable. However if you use paganation it can bring incomplete data.


Get power of your iPod with MediaChest | Minimal J2EE container is here | Light weight full J2EE stack | My blog | Co-author of "Windows programming in Turbo Pascal"
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

Duplicate post. And the answer is you have to modify the query. I'll post a longer answer in your original post on why.
[ July 19, 2007: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sort a ResultSet based on data in one of the ResultSet Columns
 
Similar Threads
Sort Jtable Column based on two conditions
PreparedStatement (displaying records)
How to sort a ResultSet
Help me to have a sortable table in my html profile!
Parsing Files with spaces