• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

ResultSet Manipulation

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I need to know, is there any possibility for us to get a limited count of records from resultset ?

Basically, the problem is , if the query result - resultset returns more than 10000 records, i couldn't able to get all the records in the Swing client..returning Out of Memory error.So, we decided to show some 5000 records to the client.Ofcourse, i can use setMaxSize() to get limited the query result.But , we have to show the total record count in another text field ..

So, my idea is , fetch all the records using resultset..
get the total count...then filter only 5000 records to display to the client...here only i need the help..is there any way to filter only limited count of records from resultset ?

Primary objective is, to finish this operation in a single database call...

I appreciate your suggesstions and ideas on this .

Thank You !
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
int a =0;
while (a<1000 && rs.next()){
a++;
//do stuff with records
}
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I would design to fire two queries. First one give me total count and the next one 5000 records.
Or
Another best solution would be to write a stored procedure which returns 2 resultset. First resultset holds the total count and next one 5000 records. This keeps the logic at one place and easy to debug, morever you can write clean code at front end.

Regards
Makarand Parab
 
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, if I remember right... There is an SQL statement that allows you to get a limited amount of record... Something like... SELECT * FROM tbl_name LIMIT 10... Something like that... I suggest you google it...
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MS SQL Server: SELECT TOP 10 * FROM bla bla
[ October 18, 2005: Message edited by: Scheepers de Bruin ]
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The syntax to limit the number of rows returned is DB-dependent. You'll need to look up which syntax is appropriate for the DV that you are using.
 
A wop bop a lu bop a womp bam boom! Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic