The temp table has 94 data records in the above structure.
Pagedemo. Java:
Public class pagedemo {public static void main (string [] ARGs) {consumer SC = new consumer (system. in); While (true) {int page = SC. nextint (); getresult (PAGE) ;}} public static int gettotalcount () {// calculate the total number of records in the data table. Int n =-1; connection conn = NULL; statement stmt = NULL; string SQL = "select count (*) Nums from temp"; try {class. forname ("oracle. JDBC. driver. oracledriver "); Conn = drivermanager. getconnection ("JDBC: oracle: thin: @ local HOST: 1521: orcl "," Scott "," Tiger "); stmt = Conn. createstatement (); resultset rs1_stmt.exe cutequery (SQL); RS. next (); n = Rs. getint ("Nums");} catch (classnotfoundexception e) {e. printstacktrace ();} catch (sqlexception e) {e. printstacktrace ();} return N;} public static int gettotalpages () {// 10 records are displayed on each page. Int totalcount = gettotalcount (); int pages = 0; if (totalcount % 10 = 0) {pages = totalcount/10;} else {pages = totalcount/10 + 1;} re Turn pages;} public static void getresult (INT page) {int from = (page-1) * 10 + 1; int to = from + 10; connection conn = NULL; preparedstatement pstmt = NULL; string SQL = "select ID, question, RN" + "from" + "(select ID, question, rownum rn from temp where rownum <?) "+" Where rn >=? "; Try {class. forname ("oracle. JDBC. driver. oracledriver "); Conn = drivermanager. getconnection ("JDBC: oracle: thin :@ localhost: 1521: orcl", "Scott", "Tiger"); pstmt = Conn. preparestatement (SQL); pstmt. setint (1, to); pstmt. setint (2, from); resultset rs1_pstmt.exe cutequery (); While (RS. next () {system. out. println (RS. getint ("ID") + ":" + Rs. getstring ("Question");} catch (classnotfoundexception e) {e. printstacktrace ();} catch (sqlexception e) {e. printstacktrace ();}}}