JDBC Drivers: When does the data move across the wire?

From: Ross Lambert <ross_at_webwolves.com>
Date: 9 Nov 2001 10:14:28 -0800
Message-ID: <5364d9d4.0111091014.7400de0_at_posting.google.com>


Folks,

If I have a large ResultSet from a query, the actual number of rows physically sent to the client initially should equal the fetch size; the rest are pulled across in fetch-sized chunks as you iterate the rows.

Question 1: After looping through the entire ResultSet via the next() method, does the ResultSet itself hold all the rows in memory? That would seem dumb since most people iterate and grab each row's data; if the ResultSet cached it as well you'd have two copies. But several folks have told me that's the way it works.

Question 2: If I do this:

ResultSet rs = stmt.execute(sql);

rs.next();             // moves to first row
rs.last();             // expensive?

...does the driver move all the records in between the first row and the last across the wire? Or does it skip right to the last row?

Since my ResultSet is potentially very large, I'm looking to be very careful about how much data I move across the network and when.

Thanks.

  • Ross ==
Received on Fri Nov 09 2001 - 19:14:28 CET

Original text of this message