📄 请教 cachedrowset 如何实现分页.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0046)http://www.it130.net/jsp/CachedRowSet-4385.htm -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>JSP,CachedRowSet 请教 CachedRowSet 如何实现分页,成功实现过的,或实例,详细最好啦</TITLE><!---->
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content=JSP,CachedRowSet name=keywords>
<META content="JSP,CachedRowSet请教 CachedRowSet 如何实现分页,成功实现过的,或实例,详细最好啦"
name=description><LINK rev=stylesheet media=all
href="请教 CachedRowSet 如何实现分页.files/file.css" type=text/css rel=stylesheet>
<META content=all name=robots>
<META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
<BODY>
<DIV id=wrapper>
<DIV id=innerWrapper>
<DIV id=header>
<DIV id=innerHeader>
<DIV class=site-header>
<DIV class=sitename><A href="http://www.it130.net/"><FONT
color=red>IT</FONT>索引<FONT color=red>者</FONT> </A></DIV>
<DIV class=site-desc>索引互联网,让您知道大家正在干什么!</DIV></DIV>
<DIV id=menu>
<UL>
<LI><A href="http://www.it130.net/program/index.htm">开发语言</A>
<LI><A href="http://www.it130.net/JAVA/index.htm">JAVA</A>
<LI><A href="http://www.it130.net/Database/index.htm">数据库开发</A>
<LI><A href="http://www.it130.net/web/index.htm">web开发</A>
<LI><A href="http://www.it130.net/OS/index.htm">操作系统</A>
<LI><A href="http://www.it130.net/application/index.htm">应用开发</A>
<LI><A href="http://www.it130.net/IT-renzheng/index.htm">IT考试与认证</A>
<LI><A
href="http://www.it130.net/Delphi/index.htm">Delphi/delphi.net</A></LI></UL></DIV></DIV></DIV>
<DIV id=main>
<DIV class=content id=content>
<DIV id=innerContent>
<DIV class=textbox>
<DIV>
<SCRIPT type=text/javascript><!--google_ad_client = "pub-1790048397430834";google_alternate_color = "ffffff";google_ad_width = 710;google_ad_height = 15;google_ad_format = "728x15_0ads_al";google_ad_channel ="0393848602";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "FFFFFF";google_color_url = "CCCCCC";google_color_text = "4C90BF";//--></SCRIPT>
<SCRIPT src="请教 CachedRowSet 如何实现分页.files/show_ads.js"
type=text/javascript></SCRIPT>
</DIV>
<DIV class=textbox-title>
<H1>JSP,CachedRowSet 请教 CachedRowSet 如何实现分页,成功实现过的,或实例,详细最好啦 </H1></DIV>
<DIV class=textbox-content>
<DIV class=problem>问题 <SPAN class=ptime>于 2006-09-14 03:59</SPAN></DIV>
<DIV class=con>一个<A class=keyurl href="http://www.it130.net/jsp/index.htm"
target=_blank>jsp</A>初学者,最近学习分页,搜索了很多关于分页的地文章,要么看不怎么懂,要么实现不了,<BR>现在用的是 JDK 1.5 +
tomcat 5.5 ,早就听说 cacherowset 可以很好很高效的解决分页问题,<BR>可是查了N多基本上都是差不多是 同样的一篇文章如下
http://topic.csdn.net/t/20050310/19/3841243.<A class=keyurl
href="http://www.it130.net/html/index.htm"
target=_blank>html</A><BR><BR>可我不怎么理解,总是没有试成功过,<BR>请各位学长帮帮忙,能提供点详细的关于cachedrowset
分页的详细点的解决方法 或者 一些实例,<BR>从心感谢!!!!<BR>
<DIV>
<SCRIPT type=text/javascript><!--google_ad_client = "pub-1790048397430834";google_ad_width = 728;google_ad_height = 90;google_ad_format = "728x90_as";google_ad_type = "text_image";google_ad_channel ="3321209211";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "0000CC";google_color_url = "008000";google_color_text = "000000";//--></SCRIPT>
<SCRIPT src="请教 CachedRowSet 如何实现分页.files/show_ads.js"
type=text/javascript></SCRIPT>
</DIV></DIV><!---->
<DIV class=ans>响应者 <SPAN class=num>1</SPAN>:</DIV>
<DIV class=con>自己顶,顶到成功.... </DIV><!---->
<DIV class=ans>响应者 <SPAN class=num>2</SPAN>:</DIV>
<DIV class=con>select top "+pagesize+" id,name,.... from [table] where id not in
(select top "pagesize*(page-1) id from [table]) order by id desc </DIV><!---->
<DIV class=ans>响应者 <SPAN class=num>3</SPAN>:</DIV>
<DIV
class=con>楼上的是在主健值不变下才行!<BR><BR>主健值乱了可能就不行了吧?<BR><BR>1<BR>2<BR>3<BR>4<BR>5<BR><BR>OK<BR><BR>3<BR>4<BR>5<BR>.<BR>.<BR><BR>出错的
</DIV><!---->
<DIV class=ans>响应者 <SPAN class=num>4</SPAN>:</DIV>
<DIV class=con>还是不怎么懂哦,继续d<BR></DIV><!---->
<DIV class=ans>响应者 <SPAN class=num>5</SPAN>:</DIV>
<DIV class=con>纯情顶 </DIV><!---->
<DIV class=ans>响应者 <SPAN class=num>6</SPAN>:</DIV>
<DIV class=con>考虑到在不同数据库中移植所以没有采用本地SQL游标方式<BR><BR><BR>/*<BR>* 创建日期
2005-11-29<BR>* 项目名称 Software.RemoteServer.Face.<A class=keyurl
href="http://www.it130.net/Database/index.htm" target=_blank>Database</A><BR>*
所在包名 jp.kernel.newage.software.remoteserver.face.<A class=keyurl
href="http://www.it130.net/Database/index.htm" target=_blank>Database</A><BR>*
版权所有 (C) 1996-2005 Ryo Hazuki<BR>*/<BR>package
jp.kernel.newage.software.remoteserver.face.<A class=keyurl
href="http://www.it130.net/Database/index.htm"
target=_blank>Database</A>;<BR><BR>import <A class=keyurl
href="http://www.it130.net/JAVA/index.htm"
target=_blank>JAVA</A>.io.Serializable;<BR>import <A class=keyurl
href="http://www.it130.net/JAVA/index.htm"
target=_blank>JAVA</A>.sql.SQLException;<BR><BR>import <A class=keyurl
href="http://www.it130.net/JAVA/index.htm"
target=_blank>JAVA</A>x.sql.RowSet;<BR>import <A class=keyurl
href="http://www.it130.net/JAVA/index.htm"
target=_blank>JAVA</A>x.sql.RowSetMetaData;<BR>import <A class=keyurl
href="http://www.it130.net/JAVA/index.htm"
target=_blank>JAVA</A>x.sql.rowset.WebRowSet;<BR><BR>import
com.sun.rowset.WebRowSetImpl;<BR><BR>/**<BR>* 可提取指定页码行集对象的包装器(实现不是十分成熟)<BR>*
<BR>* @author Ryo Hazuki<BR>* @version 1.0.0<BR>*/<BR>public class
KPageableRowSetProxy implements Serializable {<BR>/** 序列号 */<BR>private static
final long serialVersionUID = -7452021128553976465L;<BR><BR>/** 当前页码
*/<BR>protected int intAbsoultePage;<BR><BR>/** 页码总数 */<BR>protected int
intPageCount;<BR><BR>/** 包含一页记录的行集 */<BR>protected RowSet
rstProxy;<BR><BR>/**<BR>* 初始化包装器<BR>* <BR>* @param rowset<BR>* 要进行分割的行集<BR>*
@param pagesize<BR>* 每页记录行数<BR>* @param absoulte<BR>* 要生成子行集的页码<BR>* @throws
SQLException<BR>*/<BR>public KPageableRowSetProxy(RowSet rowset, int pagesize,
int absoulte)<BR>throws SQLException {<BR>if (null == rowset) {<BR>throw new
NullPointerException(getClass().getName());<BR>}<BR>int intPageSize = pagesize,
intAbsoulte = absoulte;<BR>if (1 > intPageSize) {<BR>intPageSize =
1;<BR>}<BR>if (1 > intAbsoulte) {<BR>intAbsoulte =
1;<BR>}<BR>rowset.setFetchDirection(1004);<BR>final int MAXROWS =
rowset.getMaxRows();<BR>if (MAXROWS <= intPageSize) {<BR>rstProxy =
rowset;<BR>intAbsoultePage = intPageCount = 1;<BR>} else
{<BR>rowset.absolute(intAbsoulte);<BR>WebRowSet wrsProxy = new
WebRowSetImpl();<BR>final RowSetMetaData META = (RowSetMetaData)
rowset.getMetaData();<BR>wrsProxy.setMetaData(META);<BR>while (rowset.next())
{<BR>wrsProxy.insertRow();<BR>for (int i = META.getColumnCount(); i > 0;)
{<BR>wrsProxy.setObject(i,
rowset.getObject(i--));<BR>}<BR>wrsProxy.acceptChanges();<BR>}<BR>rstProxy =
wrsProxy;<BR>intAbsoultePage = intAbsoulte;<BR>intPageCount = (MAXROWS +
intPageSize - 1) / intPageSize;<BR>}<BR>}<BR><BR>/**<BR>* 获取当前页码<BR>* <BR>*
@return 当前页码<BR>*/<BR>public int getAbsoultePage() {<BR>return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -