acerbic coffee
          走自己的路,讓別人跑步
          posts - 26,comments - 14,trackbacks - 0
          一 前提
          希望最新的紀(jì)錄在開(kāi)頭給你的表建立查詢:
          表:mytable
          查詢:create or replace view as mytable_view from mytable order by id desc 其中,最好使用序列號(hào)create sequence mytable_sequence 來(lái)自動(dòng)增加你的紀(jì)錄id號(hào)

          二 源程序
          <%String sConn="你的連接"
          Class.forName("oracle.jdbc.driver.OracleDriver");
          Connection conn=DriverManager.getConnection(sConn,"你的用戶名","密碼");
          Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENS99vIVE,ResultSet.CONCUR_UPDATABLE);
          Statement stmtcount=conn.createStatement(ResultSet.TYPE_SCROLL_SENS99vIVE,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=你的每頁(yè)顯示紀(jì)錄數(shù);
          int rowCount=0; //總的記錄數(shù)
          while (rscount
          int pageCount; //總的頁(yè)數(shù)
          int currPage; //當(dāng)前頁(yè)數(shù)

          1


          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();
          %>

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

          posted on 2006-10-18 13:37 acerbic coffee 閱讀(299) 評(píng)論(0)  編輯  收藏 所屬分類: 個(gè)人記錄
          主站蜘蛛池模板: 金堂县| 明水县| 惠水县| 大兴区| 黎川县| 商丘市| 绥芬河市| 济南市| 新闻| 黄浦区| 沭阳县| 大厂| 石狮市| 宁晋县| 诸暨市| 霍林郭勒市| 张掖市| 海盐县| 鸡西市| 江西省| 普洱| 和田市| 吴旗县| 平南县| 新野县| 两当县| 百色市| 彩票| 鹤峰县| 临漳县| 鲁甸县| 凤台县| 民丰县| 锡林郭勒盟| 巴彦淖尔市| 龙山县| 综艺| 绥芬河市| 寻乌县| 镇平县| 成武县|