Preparation: Under Oracle, create a table: CREATE TABLE MyTable (ID INT, Name Varchar (32)) /
Insert some values in Table MyTable.
The TestPage.JSP page program is as follows:
<% @ page import = "java.util. *"%> <% @ Page import = "java.lang. *"%> <% @ Page import = " Java.io. * "%> <% @ page import =" java.sql. * "%> <% @ page import =" java.net. * "%> <% @ Page ContentType =" text / html; charSet = GBK "%>
<% String sconn = "JDBC: Oracle: Thin: @HOST: 1521: ORCL"; Class.Forname ("Oracle.jdbc.driver.Oracledriver); Connection Conn = DriverManager.getConnection (Sconn," User "," PASSWORD "); Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); // Statement stmtcount = conn.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet RS = Stmt.executeQuery ("Select * from myTable"); // string sqlcount = "select count (*) from mytable"; // resultset = stmtcount.executeQuery (Sqlcount);
INT Pagesize = 5; // 5 per page INT ROWCOUNT = 0; // Total number of records
Rs.last (); rowcount = rs.getrow ();
INT pageCount; // Total page number int currpage = 0; // Current page String strpage; strPage = Request.getParameter ("Page");
if (strPage == null) {currPage = 1;} else {currPage = Integer.parseInt (strPage); if (currPage <1) currPage = 1;} pageCount = (rowCount pageSize-1) / pageSize; if (currPage > PageCount);
INT thepage = (currpage-1) * Pagesize; int N = 0;%>
Current: <% = currpage%> page
Home <% IF (Currpage> 1) {%> Next A> <%}%> Last"