wood burning stoves 2.0*
The moose likes JDBC and the fly likes How do you know number of rows fetched by ResultSet?. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How do you know number of rows fetched by ResultSet?." Watch "How do you know number of rows fetched by ResultSet?." New topic
Author

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

narender kaasam
Greenhorn

Joined: May 15, 2006
Posts: 28
How do you know number of rows fetched by ResultSet?.
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

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


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
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
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

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

Joined: Dec 15, 2005
Posts: 333
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you know number of rows fetched by ResultSet?.