• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do you know number of rows fetched by ResultSet?.

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you know number of rows fetched by ResultSet?.
 
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there are several ways ,
one is to use setFetchsize(), by this way you set the fetch size explicity

The other one is to execute a select count(...) statement after or before your orijinal statement execution .

another way is to count the rows one by one

and the last way that i know is
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Masoud Kalali:
there are several ways ,
one is to use setFetchsize(), by this way you set the fetch size explicity

[/CODE]



setFetchSize does NOT affect the number of rows in the ResultSet; it affects the number of rows that are buffered by the driver. It's a performance optimization setting, not a logical operation. Some drivers default their fetch size to "all rows" and will run the JVM out of memory with a very large ResultSet, some drivers have a default fetch size of 1 and therefore spend too much time waiting on network transfers of data, some drivers have a default fetch size that is larger but may not be optimal for any particular situation (the Oracle driver has default fetch size of 10 and people usually get better performance with a higher value for the fetch size).
 
Masoud Kalali
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by narender kaasam:
How do you know number of rows fetched by ResultSet?.




maybe i did not understand the question.
 
stu derby
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Masoud Kalali:



maybe i did not understand the question.



More likely, you understood the question and meant to say "setMaxRows()" instead of "setFetchSize()".

setMaxRows() does what the name implies, limits the size of the returned ResultSet, so you know that your ResultSet is that size or smaller...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic