Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

About ResultSet

Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I searched the net for ResultSet and read some about it.I want to listen to your advices,experiences too.

*How does ResultSet work?

*What is Fetch size?

Does ResultSet get all data from db only at once?

Thank you.
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


There exists Statement.setMaxRows() which does the same on the Statement Interface.

You can then use ORDER BY DESC/ASC and get the results you need.
author & internet detective
Posts: 40200
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ResultSet provides an interface that the database driver implements to pass you the results of a query. Fetch size is the number of rows the driver gets in each trip to the database. A ResultSet gets all the data at once if the fetch size is larger than the number of rows. Otherwise, it gets it in chunks.
Yilmaz Mete
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see sth here....

About the Fetch Size Attribute

Each ResultSet object has a fetch size attribute. This attribute controls how many rows the driver should retrieve from the server in each server request.

If fetch size is 1, the driver will get one row from the server with each method call.

If the fetch size is 20, the driver will get twenty rows from the server on the first All 20 rows will be kept in the driver network buffer. The subsequent 19 calls will not talk to the server at all. On the 20th the server will be asked for the next 20 rows.

The driver is not required to use the fetch size strictly. The driver should use the fetch size only as a recommendation from the application. However, Mimer JDBC does follow a specified fetch size.

When the ResultSet object is created, it inherits the fetch size from the statement object (Statement, PreparedStatement or CallableStatement) that created the ResultSet. The fetch size attribute for the statement object can be manipulated just like the ResultSet attribute but its sole purpose is to provide a default for ResultSet objects.

If the application does not specify a fetch size at all, Mimer JDBC will use whatever fetch size that fits into a 60Kb buffer. If each row takes up 100 bytes the default fetch size will be 600.


How do I set the fetch size?

There are two ways you can set the fetch size:
Set the fetch size on the statement object, thus affecting all ResultSet objects created by the statement object
Set the fetch size individually on each ResultSet object created.

For example, the code sample below creates a PreparedStatement and sets the default fetch size to 1000 rows. This setting could be suitable for a non-interactive caller. Sometimes an interactive part of the application wants to present the same information to the user one screen at a time. In this case, a result set is created from the PreparedStatement and the fetch size is set to 20.

[ August 10, 2005: Message edited by: Yilmaz Mete ]
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic