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

retrieve values randomly ?

 
Saurabh Naik
Ranch Hand
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can I retrieve values from database randomly ?
suppose in my database there are 13 rows . and I want to retrieve these in random order ?
is there any method to do it ?
 
Sandeep Kumar S Jakkaraju
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can do "order by rand()" .....if it is an rdbms ......
 
Scott Selikoff
author
Saloon Keeper
Posts: 3900
16
Eclipse IDE Flex Google Web Toolkit
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really. The best solution would be to randomize the returned data in the object/list/array you are storing them in.
 
Scott Selikoff
author
Saloon Keeper
Posts: 3900
16
Eclipse IDE Flex Google Web Toolkit
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How many records are we talking about? Unless your passing the result set to the presentation layer (scary) I don't see how your not putting things into memory. A resultset is just a database-backed hashmap.
 
Saurabh Naik
Ranch Hand
Posts: 87
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jean.. it works with order by rand()..
but is there any mechanism to fetch result randomly through function..
what is this ResultSet.FETCH_UNKNOWN... how to use it ?
 
Scott Selikoff
author
Saloon Keeper
Posts: 3900
16
Eclipse IDE Flex Google Web Toolkit
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no method in java to randomize result sets but it would be trivial to do so in an application.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic