Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the workings of ResultSet.getFetchSize()

 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a method which looks something like this:

The validate method does the following to return an int:

(broken up the lines for display)
In the UserBean, there is a method isUserValid() and that checks whether validate returns greater than 0.
Unfortunately, whether the user is valid or not, the result is always 0. I have another method called queryResultsAL() which returns an ArrayList of results, if I subsitute the above code with following:

Then this works (unfortunately also returns greater than 0 when no username and password are specified but there will be validations to ensure empty strings never reach that code).
I am somewhat confused about the workings of getFetchSize() which I thought will return how many results are retrieved by the query.
Can any one help me to understand this and correct my understanding.
Regards
Faisal
[ February 10, 2004: Message edited by: Faisal Khan ]
 
Peyton McCullough
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not exactly sure what getFetchSize() does. Though I do know of another method to count the number of results:

Maybe that will aid you.
 
Joe Nguyen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faisal,
GetFetchSize() returns the number of records that database fetch to your applicaton at a time. By default, the fetch size is 10. Let's assume that your query result contains 100 records. It would takes 10 round trips to transfer 100 records to your application (10 x 10 = 100). GetFetchSize() does not return the number of records in the resultset. If you need to ensure that there is at least one record.
return resultset.next();
Otherwise, loop and cound
while(result.next){
rowCount++
}
You would be in better shape when using PreparedStatement since much overhead is reduced.
Hope it help
 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for the feedback and clarification of getFetchSize().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic