<%@ page language= "java" import= "java.util.*,java.sql.*" pageencoding= "Utf-8"%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" > <title>oracle Page Case </title> <meta http-equiv= "Pragma" content= "No-cache" > <meta http-equiv= "Cache-control" content= "No-cache" > <body> <table> <tr> <td> Employee Name </td> <td> Salary </td> </tr> <% Query Total Pages int pagecount = 0; There are a total of several records int rowcount = 0; Show several records per page int pageSize = 3; Receive the current number of pages String Strpagenow = Request.getparameter ("Pagenow"); int pagenow = 1; if (strpagenow!=null) { Pagenow = integer.valueof (Strpagenow); } Connection conn = null; Statement stmt = null; Try { Load Driver Class.forName ("Oracle.jdbc.driver.OracleDriver"); Get Connected conn = Drivermanager.getconnection ("Jdbc:oracle:thin:@127.0.0.1:1521:orcl", "Scott", "Tiger"); stmt = Conn.createstatement (); ResultSet rs= stmt.executequery ("SELECT count (*) from EMP"); while (Rs.next ()) { RowCount = Rs.getint (1); if (rowcount%pagesize = 0) { PageCount = rowcount/pagesize; } Else { PageCount = rowcount/pagesize + 1; } } rs = Stmt.executequery ("SELECT *" (select T.*,rownum rn from (SELECT * from emp) t where rownum <= "+ pagenow*pages Ize + ") where RN >=" + ((pageNow-1) *pagesize + 1) + ""); while (Rs.next ()) { Out.print ("<tr>"); Out.print ("<td>" +rs.getstring (2) + "</td>"); Out.print ("<td>" +rs.getint (6) + "</td>"); Out.print ("</tr>"); } Out.print ("<tr>"); for (int i =1; i<=pagecount; i++) { Out.print ("<a href=" testoracle.jsp?pagenow= "+i+" ">[" +i+ "]</a>"); } Out.print ("</tr>"); } catch (Exception e) { throw new RuntimeException (e); } Finally { Try { if (stmt!= null) { Stmt.close (); } IF (conn!= null) { Conn.close (); } } catch (Exception ex) { throw new RuntimeException (ex); } } %> </table> </body> |