新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
DB2分頁(yè)的實(shí)現(xiàn)
下文為您介紹DB2分頁(yè)的腳本,供您參考學(xué)習(xí),如果您對(duì)DB2分頁(yè)方面感興趣的話,不妨一看,相信對(duì)您學(xué)習(xí)DB2分頁(yè)會(huì)有所啟迪。

創(chuàng)新互聯(lián)公司-專(zhuān)業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性?xún)r(jià)比麗江網(wǎng)站開(kāi)發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式麗江網(wǎng)站制作公司更省心,省錢(qián),快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋麗江地區(qū)。費(fèi)用合理售后完善,十年實(shí)體公司更值得信賴(lài)。
- String sqlcount="select count(*) from stu.book "+condition;
- System.out.println(sqlcount);
- int curPage; //當(dāng)前需要顯示的頁(yè)碼
- int totalPages; //總頁(yè)數(shù)
- int pageRecord=10; //每頁(yè)要顯示的記錄條數(shù)
- int totalRecords; //滿(mǎn)足條件的總共的記錄條數(shù)
- if(CPage!=null ){
- curPage =Integer.parseInt(CPage);
- if(curPage<1){
- curPage=1;
- }
- }else{
- curPage=1;
- }
- Connection con=Dao.getConn(); //獲取數(shù)據(jù)庫(kù)連接
- try {
- ps=con.prepareStatement(sqlcount);
- rs=ps.executeQuery();
- if(rs.next()){
- totalRecords=rs.getInt(1);
- if(totalRecords%pageRecord==0)
- totalPages=totalRecords/pageRecord;//當(dāng)每頁(yè)顯示的記錄條數(shù)能被總記錄條數(shù)整除時(shí) 總頁(yè)數(shù)為總記錄條數(shù)除以每頁(yè)顯示的記錄條數(shù)
- else
- totalPages=totalRecords/pageRecord+1;//當(dāng)每頁(yè)顯示的記錄條數(shù)不能被總記錄條數(shù)整除時(shí) 總頁(yè)數(shù)為總記錄條數(shù)除以每頁(yè)顯示的記錄條數(shù)的商再加1
- String sql;
- if(curPage==1){
- sql="select * from stu.book "+condition+" FETCH FIRST "+ pageRecord+" ROWS ONLY";
- }else{
- sql="select * from stu.book "+condition+" and booknum not in ( select booknum from stu.book "+condition+" FETCH FIRST "+(curPage-1)*pageRecord+" ROWS ONLY )"+" FETCH FIRST "+ pageRecord+" ROWS ONLY";
- }
- System.out.println(sql);
- ps=con.prepareStatement(sql);
- rs=ps.executeQuery();
- while(rs.next()){
- Book b=new Book();
- b.setBooknum(rs.getString(1));
- b.setBookname(rs.getString(2));
- b.setBookindate(rs.getString(3));
- b.setBorrower(rs.getString(4));
- b.setLenddate(rs.getString(5));
- b.setRemark(rs.getString(6));
- al.add(b);
- }
- }else{
- return al;
- }
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- return al;
以上就是DB2分頁(yè)的實(shí)現(xiàn)方法。
【編輯推薦】
DB2游標(biāo)及其使用
DB2表空間的管理方式
DB2數(shù)據(jù)庫(kù)權(quán)限介紹
三種DB2表靜默狀態(tài)
DB2數(shù)據(jù)庫(kù)卸載的問(wèn)題診斷
標(biāo)題名稱(chēng):DB2分頁(yè)的實(shí)現(xiàn)
當(dāng)前路徑:http://www.5511xx.com/article/dpcejcp.html
其他資訊
- 域名過(guò)期多久能注冊(cè)?(域名過(guò)期多久能注冊(cè)商標(biāo))
- 如何備份數(shù)據(jù)庫(kù)?尋找數(shù)據(jù)庫(kù)文件存放位置(數(shù)據(jù)庫(kù)怎樣備份數(shù)據(jù)庫(kù)文件在哪里找)
- 域名轉(zhuǎn)入什么意思?(這個(gè)域名轉(zhuǎn)移失敗錢(qián)退了我重新提交還是怎么辦)
- Redis讀寫(xiě)實(shí)現(xiàn)快速數(shù)據(jù)訪問(wèn)(redis讀寫(xiě)實(shí)現(xiàn))
- windowsxp進(jìn)入pe?(xp進(jìn)入pe系統(tǒng))


咨詢(xún)
建站咨詢(xún)
