Quote:
Originally posted by cesar
Hello,
I'm accessing a DB2 table through a Java classes using JDBC:
String query="SELECT ... FROM ...";
Statement stmt;
ResultSet rs;
...
rs=stmt.executeQuery(query);
The problem is that the query may return a huge number of columns and I would like to retrieve the results by batches of 100 rows, for example (like a buffer).
Anybody has an idea?
Thanks,
Cesar
|
There's no way to influence the JDBC driver. You could manually "partition" the result set into more manageable chunks by either restricting the search with an additional condition (such as date or sequence number or something like that) or using SELECT ... FETCH FIRST ... ROWS ONLY.
It really depends on what your application is doing with the result set. If it's intended for user browsing then restriction mentioned above should suit your needs - users are rarely interested in something more than 2-3 screenfuls of data. If they want to browse further you would issue a query for the next chunk of data.
If, on the other hand, you do some kind of automated processing of the retrived data (like computing something) then you might want to shift these computations to the database server (by creating a UDF if necessary) and then retrieving the result of the computation.
I hope this makes sense...
Nick