<%
// Variable Declaration
Java. SQL. Connection sqlcon; // database connection object
Java. SQL. Statement sqlstmt; // SQL statement object
Java. SQL. resultset sqlrst; // result set object
Java. Lang. String strcon; // database connection string
Java. Lang. String strsql; // SQL statement
Int intpagesize; // number of records displayed on one page
Int introwcount; // The total number of records.
Int intpagecount; // the total number of pages.
Int intpage; // the page number to be displayed.
Int layer;
Int idlayer;
Idlayer = 1;
Java. Lang. String outtext;
Outtext = "";
Java. Lang. String strpage;
Int J;
Int I;
// Set the number of records displayed on one page
Intpagesize = 10;
// Obtain the page number to be displayed
Strpage = request. getparameter ("page ");
If (strpage = NULL) {// indicates that the page parameter is not found in querystring. the first page of data is displayed.
Intpage = 1;
}
Else {// convert a string to an integer
Intpage = java. Lang. Integer. parseint (strpage );
If (intpage <1) intpage = 1;
}
// Load the JDBC driver
Class. forname ("org. gjt. Mm. MySQL. Driver"). newinstance ();
// Connect to the database
Sqlcon = java. SQL. drivermanager. getconnection ("JDBC: mysql: // 218.22.156.3/kjeny_db", "kjeny", "cdgame ");
// Create a statement object
Sqlstmt = sqlcon. createstatement (Java. SQL. resultset. type_scroll_insensitive, java. SQL. resultset. concur_read_only );
// Execute the SQL statement and obtain the result set
Sqlrst = sqlstmt.exe cutequery ("select * From dxswlxh ");
// Obtain the total number of records
Sqlrst. Last ();
Introwcount = sqlrst. getrow ();
// Calculate the total number of pages
Intpagecount = (introwcount + intPageSize-1)/intpagesize;
// Adjust the page number to be displayed
If (intpage> intpagecount) intpage = intpagecount;
%>
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Base target = "contents">
<LINK rel = "stylesheet" href = "css.css">
<Script language = "JavaScript">
Function bytelen (STR ){
VaR ibytelen = 0;
If (STR = NULL | STR = ""){
Ibytelen = 0;
} Else {
For (VAR I = 0; I <Str. length; I ++ ){
If (Str. charcodeat (I) <0x80 ){
Ibytelen ++;
} Else {
Ibytelen + = 2;
}
}
}
Return ibytelen;
}
</SCRIPT>
</Head>
<Body topmargin = "0" leftmargin = "0" bgcolor = ccffcc>
<Table width = "100%"> <tr> <TD bgcolor = "ff66cc">
> Paging
<Form method = post action = "pink. jsp? Page = 1 "target = ttop>
<Input type = submit value = "first page">
</Form>
<% IF (intpage> 1 ){
%>
<Form method = post action = "pink. jsp? Page = intPage-1 %> "target = ttop>
<Input type = submit value = Previous Page>
</Form>
<% }%>
<% IF (intpage <intpagecount)
{%>
<Form method = post action = "pink. jsp? Page = <% = intpage + 1%> "target = ttop>
<Input type = submit value = next page>
</Form>
<% }%>
<Form method = post action = "pink. jsp? Page = <% = intpagecount %> "target = ttop>
<Input type = submit value = "last page">
</Form>
Page: <% = intpage %>/<% = intpagecount %> page <% = intpagesize %> entries/Page
</TD> </tr> </table>
<Table>
<TD width = "% 100"> <ul> <%
If (intpagecount> 0 ){
Sqlrst. Absolute (intPage-1) * intpagesize + 1 );
I = 0;
While (I <intpagesize &&! Sqlrst. isafterlast ()){
String names = sqlrst. getstring (3 );
String use_xi = sqlrst. getstring (4 );
%>
<Li> <% = names %>-[<% = use_xi %>]
<%
Sqlrst. Next ();
I ++;
}
}
%>
</Ul> </TD> </table>
</Body>
</Html>
<%
// Close the result set
Sqlrst. Close ();
// Close the SQL statement object
Sqlstmt. Close ();
// Close the database
Sqlcon. Close ();
%>