<%
//變量聲明
java.sql.Connection sqlCon; //數據庫連接對象
java.sql.Statement sqlStmt; //SQL語句對象
java.sql.ResultSet sqlRst; //結果集對象
java.lang.String strCon; //數據庫連接字符串
java.lang.String strSQL; //SQL語句
int intPageSize; //一頁顯示的記錄數
int intRowCount; //記錄總數
int intPageCount; //總頁數
int intPage; //待顯示頁碼
int layer;
int idlayer;
idlayer=1;
java.lang.String outtext;
outtext=”";
java.lang.String strPage;
int j;
int i;
//設置一頁顯示的記錄數
intPageSize = 10;
//取得待顯示頁碼
strPage = request.getParameter(”page”);
if(strPage==null){//表明在QueryString中沒有page這一個參數,此時顯示第一頁數據
intPage = 1;
}
else{//將字符串轉換成整型
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
//裝載JDBC驅動程序
Class.forName(”org.gjt.mm.mysql.Driver”).newInstance();
//連接數據庫
sqlCon = java.sql.DriverManager.getConnection(”jdbc:mysql://218.22.156.3/kjeny_db”,”kjeny”,”cdgame”);
//創建語句對象
sqlStmt = sqlCon.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
//執行SQL語句並獲取結果集
sqlRst = sqlStmt.executeQuery(”SELECT * FROM dxswlxh”);
//獲取記錄總數
sqlRst.last();
intRowCount = sqlRst.getRow();
//記算總頁數
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//調整待顯示的頁碼
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) < 0×80) {
iByteLen++;
} else {
iByteLen += 2;
}
}
}
return iByteLen;
}
</script>
</head>
<body topmargin=”0″ leftmargin=”0″ bgcolor=ccffcc>