国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

詳細的jsp分頁(oracle+jsp+apache)

2019-11-18 16:33:10
字體:
來源:轉載
供稿:網友

我的一個詳細的jsp分頁程序!(Oracle+jsp+apache)
一 前提
希望最新的紀錄在開頭給你的表建立查詢:
表:mytable
查詢:create or replace view as mytable_view from mytable order by id desc 其中,最好使用序列號create sequence mytable_sequence 來自動增加你的紀錄id號

二 源程序
<%String sConn="你的連接"
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection(sConn,"你的用戶名","密碼");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmtcount=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

ResultSet rs=stmt.executeQuery("select * from mytable_view");
String sqlcount="select count(*) from mytable_view";
ResultSet rscount=stmtcount.executeQuery(sqlcount);

int pageSize=你的每頁顯示紀錄數;
int rowCount=0; //總的記錄數
while (rscount
int pageCount; //總的頁數
int currPage; //當前頁數
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) currPage=pageCount;

int thepage=(currPage-1)*pageSize;
int n=0;
rs.absolute(thepage+1);
while (n<(pageSize)&&!rs
%>
<%rs.close();
rscount.close();
stmt.close();
stmtcount.close();
conn.close();
%>

//下面是 第幾頁等
<form name="sinfo" method="post" action="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>" onSubmit="return testform(this)">
第<%=currPage%>頁 共<%=pageCount%>頁 共<%=rowCount%>條
<%if(currPage>1){%><a href="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>">首頁</a><%}%>
<%if(currPage>1){%><a href="sbinfo_index.jsp?page=<%=currPage-1%>&condition=<%=condition%>&type=<%=type%>">上一頁</a><%}%>
<%if(currPage<pageCount){%><a href="sbinfo_index.jsp?page=<%=currPage+1%>&condition=<%=condition%>&type=<%=type%>">下一頁</a><%}%>
<%if(pageCount>1){%><a href="sbinfo_index.jsp?page=<%=pageCount%>&condition=<%=condition%>&type=<%=type%>">尾頁</a><%}%>
跳到<input type="text" name="page" size="4" style="font-size:9px">頁
<input type="submit" name="submit" size="4" value="GO" style="font-size:9px">
</form> 
 

 完


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 太仓市| 天津市| 龙川县| 博客| 蓬莱市| 江华| 贵港市| 塔河县| 德江县| 银川市| 卢龙县| 闵行区| 大同市| 轮台县| 晋宁县| 开封市| 江华| 吉水县| 长子县| 庆云县| 奇台县| 静乐县| 固镇县| 高台县| 温州市| 监利县| 开平市| 靖西县| 通海县| 南昌县| 西平县| 靖江市| 乡宁县| 福泉市| 克山县| 琼海市| 黑水县| 定陶县| 深水埗区| 上饶县| 铜山县|