• 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

About ResultSet

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


OR

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: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sinasi,
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
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
see sth here....
http://developer.mimer.com/howto/howto_33.htm

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 ResultSet.next() method call.

If the fetch size is 20, the driver will get twenty rows from the server on the first ResultSet.next(). All 20 rows will be kept in the driver network buffer. The subsequent 19 ResultSet.next() calls will not talk to the server at all. On the 20th ResultSet.next() 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.


Example

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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic