码迷,mamicode.com
首页 > 其他好文 > 详细

ResultSet取结果集多少条记录方法及分页概要

时间:2015-01-14 12:39:53      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

		allst=toconn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
		allsql = "SELECT distinct docid,docchannel FROM isimportant where docchannel=‘"+CHANNELID+"‘";		
		allrs=allst.executeQuery(allsql);
		allrs.last();
		int recordcount=allrs.getRow();
		allrs.beforeFirst();
	
		int pagesize;
		pagesize=12;
		int pagecount;
		if(recordcount%pagesize!=0)
			pagecount=recordcount/pagesize+1;
		else
			pagecount=recordcount/pagesize;
	
		if(pagecount==0)
			pagecount=1;
	    int topage=1;
		String strtopage=request.getParameter("topage");
		if (strtopage==null)
		{
			topage=1;
		}
		else
		{
			topage=Integer.parseInt(strtopage);
		}
		if(pagecount<=0)
			pagecount=1;
		if(topage<=0)
			topage=1;
		if(topage>pagecount)
			topage=pagecount;
		if(topage>1)
			allrs.absolute(pagesize*(topage-1));
		String iscount="";
		while(allrs.next()&&isum<pagesize){........}
///////////////分页
<ul class="pagination">	     
            <%		   	
					if( topage > 1)
					{
				%>            
				<li><a href="./manager/mmain.jsp?topage=1&CHANNELID=<%=CHANNELID%>" class="">首页</a></li>               
				<li><a href="./manager/mmain.jsp?topage=<%=(topage-1)%>&CHANNELID=<%=CHANNELID%>" class="">上一页</a></li> 
				<%
					}
					else
					{
				%>     
										<li class="previous disabled"><a class="">首页</a></li> 
										<li class="previous disabled"><a class="">上一页</a></li> 
										
				<%
					}
					if(topage<pagecount)
					{
				%> 	

										<li><a>当前第<%=topage%>页</a></li> <li><a href="./manager/mmain.jsp?topage=<%=(topage+1)%>&CHANNELID=<%=CHANNELID%>" class="">下一页</a></li> 
										<li><a href="./manager/mmain.jsp?topage=<%=pagecount%>&CHANNELID=<%=CHANNELID%>" class="">尾页</a></li> 
										<li><a> 共 <%=pagecount%> 页</a></li>
				<%
					}
				  else
					{
				%>
										<li><a>当前第<%=topage%>页</a></li> 
										<li class="next disabled"><a >下一页</a></li> 
										<li class="next disabled"><a >尾页</a></li> 
										<li><a>  共 <%=pagecount%> 页</a></li>
				<%
					}
				%>
		</ul>

 

ResultSet取结果集多少条记录方法及分页概要

标签:

原文地址:http://www.cnblogs.com/dreamzhiya/p/4223478.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!