aspose file tools*
The moose likes JDBC and the fly likes How can i group certain columns in a ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How can i group certain columns in a ResultSet" Watch "How can i group certain columns in a ResultSet" New topic
Author

How can i group certain columns in a ResultSet

Tarun Chatterjee
Greenhorn

Joined: Mar 07, 2005
Posts: 25
I have a generic query to retrieve the result from the Database
Once the result is returned back, I want to show the information in various formats eseentially group by different columns.
Is there any way i can do that in a Result set ?
Susanta Chatterjee
Ranch Hand

Joined: Aug 12, 2002
Posts: 102
No, you cannot apply any of the "group by" technique on ResultSet object.

You can apply group by in the query itself, or otherwise, you can do some java coding to achieve that.
Tarun Chatterjee
Greenhorn

Joined: Mar 07, 2005
Posts: 25
Is there any 3rd party framework which can do that ?
Or do i ahve to write a custom component for grouping the Data ?
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

You really need to write your own. There are data management tools, but its kind of a vague area since almost all database-driven applications would fall under the category of data management tools.

You can easily store the contents of the result set in an array of HashMaps since essentially a single record is equivalent to a Map. Then, you just need to sort the data over the array of maps, and/or build simplified indexes over the array as needed.


My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i group certain columns in a ResultSet