Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Limiting Large Result Sets
smartnhandsome_at_gmail.com wrote:
> So the user gets back a result for the first 10 rows, now the user
> again requests another set of 10 rows. This method is again called and
> here is the real problem starts he now wants to get results from 11-20.
> Simply put the question is how to maintain the state of the results
> with out modifying the query the user inputs??
Hi smartnhandsome (LOL, that's pretty good!),
Why can't you do something like the following?
import java.sql.*;
public class getRows {
public static void main(String args[]) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@myhost:myport/myservice","foo","foo"); conn.createStatement().executeUpdate("alter session set events '10046 trace name context forever, level 12'"); PreparedStatement pstmt = conn.prepareStatement("select * from big_table"); pstmt.setMaxRows(1000); ResultSet rst = pstmt.executeQuery(); int i = 1; while (rst.next()) { if ( ++i % 100 == 0 ) { //fetch 100 rows a time System.out.println(i); Thread.sleep(3000); //wait for a sleeper thread that isposted when the user sends it something before moving on to the next set of rows up to 1000 or whatever.
} }
Regards,
Steve Received on Wed Aug 30 2006 - 14:57:04 CDT