This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi everybody. I have the following problem. I need to get a ResultSet from a database and then display all of its rows in random order. And I would like to do then in the most elegant way. My best solution so far was to make an array of numbers from 1 to whatever the number of records in the ResultSet is, than jumble the array up with a simple mixing algorithm, and finally read the rows from the ResultSet sequentially using the number from this array and the ResultSet.absolute(int) method. I don't think this is the most effective solution though, and I was wondering whether there was an easier way. So, ideas anyone? [ February 26, 2004: Message edited by: Baba Bizlowsky ]
Baba, I would copy the records from the resultset into another data structure (array, arraylist, ...) first, so you can close the resultset. You can use your mixing algorithm on this data structure and then loop through it to display the results.