<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    blogjava's web log

    blogjava's web log
    ...

    分頁

    <% @?page?contentType = " text/html;charset=gb2312 " ? %>
    <% @?page?errorPage = " jsp1_error.jsp " ?? import = " java.util.*,?java.sql.* " ? %>
    <%
    // String?sConn="jdbc:oracle:thin:@local:1521:test"?;
    String?sConn = " jdbc:odbc:test " ;
    // String?cl="oracle.jdbc.driver.OracleDriver";
    ??String?sq2 = " sun.jdbc.odbc.JdbcOdbcDriver " ;
    Class.forName(sq2);
    Connection?conn
    = DriverManager.getConnection(sConn, " sa " , "" );
    // Connection?conn=DriverManager.getConnection(sConn,"admin","admin");
    Statement?stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY?);
    Statement?stmtcount
    = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY?);

    ResultSet?rs
    = stmt.executeQuery( " select?*?from?jobs " );
    String?sqlcount
    = " select?count(*)?as?count1?from?jobs " ;
    ResultSet?rscount
    = stmtcount.executeQuery(sqlcount);
    // rscount.last()?;
    // rscount.getRow()?;

    int ?pageSize = 3 ; // 一頁所包括的行數
    int ?rowCount = 0 ;? // 總的記錄數
    while (rscount.next())
    ??
    {
    ???rowCount
    = rscount.getInt( " count1 " ); // 取的表總的記錄數
    ??}

    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 = 1 ;? // 控制變量
    if (thepage != 0 )

    ?rs.absolute(thepage);
    // 光標下移thepage+1?行
    ? else
    ??rs.beforeFirst()?;
    ??
    // ??rs.absolute(1);

    %>
    < div?id = " Layer1 " ?align = " center " ?style = ? " background-color:?#999999 " >
    <%= currPage %> 頁?共 <%= pageCount %> 頁?共 <%= rowCount %>
    <% if (currPage > 1 ) { %>< a?href = " jsp1.jsp?page=1 " > 首頁 </ a ><% } %>
    <% if (currPage > 1 ) { %>< a?href = " jsp1.jsp?page=<%=currPage-1%> " > 上一頁 </ a ><% } %>
    <% if (currPage < pageCount) { %>< a?href = " jsp1.jsp?page=<%=currPage+1%> " > 下一頁 </ a ><% } %>
    <% if (pageCount > 1 ) { %>< a?href = " jsp1.jsp?page=<%=pageCount%> " > 尾頁 </ a ><% } %>
    ?
    < table?border = 1 ?cellspacing = " 1 " ?cellpadding = " 1 " >
    ???
    < tr >
    ????
    < td > 工號 < td >
    ????
    < td > 描述 < td >
    ????
    < td > 最小工資 < td >
    ????
    < td > 最大工資 < td >
    ???
    </ tr >
    <%
    while ?(n <= 3 ? && ?rs.next()) // 當n<=一頁的行數時
    {

    %>
    ??
    < tr >
    ????
    < td ><%= rs.getInt( 1 ) %>< td >
    ????
    < td ><%= rs.getString( 2 ) %>< td >
    ????
    < td ><%= rs.getInt( 3 ) %>< td >
    ????
    < td ><%= rs.getInt( 4 ) %>< td >
    ???
    </ tr >
    ??
    <%

    // ?if((thepage+n)==rowCount)? // 如果當前行數大于總的行數跳出循環
    // ????break;

    ??n
    ++ ; // 控制變量加一

    }


    %>
    </ table >
    </ div >
    <%
    rs.close();
    rscount.close();
    stmt.close();
    stmtcount.close();
    conn.close();
    %>




    下面來源:不詳

    select top 10 b.* from (select top 20 主鍵字段,排序字段 from 表名 order by 排序字段 desc) a,表名 b where b.主鍵字段 = a.主鍵字段 order by a.排序字段

    10 = 每頁記錄數

    20 = (當前頁 + 1) * 每頁記錄數


    1。用next()方法,
    選從50-100行
    int CurrentRow = 1;
    int MinRow = 50;
    int MaxRow = 100;
    while(rs.next())
    {
    if (CurrentRow

    {
    CurrentRow++;
    continue;
    }
    }
    2.用absolute(int row)定位
    先定位到50行,然后next();
    3.用sql完成
    SqlServer的語句:select top 50 * from (select top 100 * from sysobjects order by id) as a order by id desc
    Oracle的語句:
    select * from (select rownum r ,* from test) ss
    where ss.r > 50 and ss.r <= 100;
    測試速度 :
    absolute()最慢;定位到10000條以后無法忍受!
    next();前面幾條快,越往后越慢!
    SqlServer語句,比next快很多,但也是越往后越慢!
    Oracle語句,最快!幾乎不受條數影響!

    posted on 2006-05-06 09:42 record java and net 閱讀(276) 評論(0)  編輯  收藏 所屬分類: Jsp&&Web

    導航

    常用鏈接

    留言簿(44)

    新聞檔案

    2.動態語言

    3.工具箱

    9.文檔教程

    友情鏈接

    搜索

    最新評論

    主站蜘蛛池模板: 91亚洲国产成人精品下载| 久久久久亚洲AV综合波多野结衣| 亚洲国产精华液网站w| 一道本在线免费视频| 亚洲国产精品一区二区第一页免| 亚洲av中文无码字幕色不卡| 在线jyzzjyzz免费视频| 三级网站免费观看| 在线精品亚洲一区二区三区| jizz在线免费观看| 亚洲精品狼友在线播放| 免费黄网站在线看| 亚洲韩国—中文字幕| 中文字幕无码播放免费| 亚洲国产91在线| 国产免费人人看大香伊| 一边摸一边桶一边脱免费视频| 亚洲色欲久久久综合网| 日本免费人成网ww555在线| 亚洲最大黄色网址| 成人au免费视频影院| 男女污污污超污视频免费在线看| 98精品全国免费观看视频| 亚洲综合激情九月婷婷| 在线观看免费高清视频| 黄色a三级免费看| 久久亚洲精品成人综合| 青草草色A免费观看在线| 国产精品无码亚洲一区二区三区| 亚洲精品第一国产综合精品99| 中国好声音第二季免费播放| 精品无码一区二区三区亚洲桃色| 无码永久免费AV网站| 大片免费观看92在线视频线视频| 亚洲电影一区二区| 在线观看人成网站深夜免费| 老司机精品免费视频| 亚洲美女视频网站| 免费乱理伦在线播放| 久久久久久久99精品免费观看| 亚洲一区二区三区写真 |