• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

the workings of ResultSet.getFetchSize()

 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys for the feedback and clarification of getFetchSize().
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic