• 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

getFetchSize().... what is it for

 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
i want to find out the number of rows in a result set before proceesing it.
i used getFetchSize() for this but this method is returning 1 always.
i want to know what is the significance of this method and is there any method in jdbc 2.0 to find out the number of rows in a resultset.
regards
deeksha
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to JDBC 2.0, It Returns the fetch size for this result set...I have never tried to use it.
What you can also do is issue a select count (*) before executing your querry.
Bosun
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Here is a solution for ur problem
Statement statement = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = statement.executeQuery(query);
rs.last();
int numberOfRows = rs.getRow();
rs.beforeFirst();
mail me if u have any questions
sateesh

Originally posted by deekasha gunwant:
hi all,
i want to find out the number of rows in a result set before proceesing it.
i used getFetchSize() for this but this method is returning 1 always.
i want to know what is the significance of this method and is there any method in jdbc 2.0 to find out the number of rows in a resultset.
regards
deeksha


 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
topic covered already in this(and many more previous posts) http://www.javaranch.com/ubb/Forum3/HTML/001865.html
compares the two techniques for retrieving row counts.

Jamie
[ February 01, 2006: Message edited by: Marilyn de Queiroz ]
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and what is FetchSize?
The number of rows that should be fetched from the database each time new rows are needed. This is much different than the total number of rows.
For example, if your query finds 10,000 matches, it won't return all 10,000 rows from the database. This is where fetch size comes in to play. If fetchSize is 10, then it will initially retrieve the first ten rows. When you call rs.next() after row ten, the program makes a call to the database to return the next 10(or whatever the fetchSize is) rows.
Jamie
 
Legend has it that if you rub the right tiny ad, a genie comes out.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic