JSP+SQLSERVER的分页问题package bean; 
import java.sql.*; 
public class conn { 
Connection con=null; 
ResultSet rs=null; 
public conn(){ 
try{ 
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); 

catch(ClassNotFoundException e){ 
System.err.println(e.getMessage()); 


public ResultSet executeQuery(String sql){ 
try{ 
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=andy","sa",""); 
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); 
rs=stmt.executeQuery(sql); 

catch(SQLException e){ 
System.err.println(e.getMessage()); 

return rs; 

public int executeUpdate(String sql){ 
int result=0; 
try{ 
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=andy","sa",""); 
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); 
result=stmt.executeUpdate(sql); 

catch(SQLException ex){ 
System.out.println(ex.getMessage()); 

return result; 

} jsp文件:<%@ page contentType="text/html; charset=GBK" %> 
<%@ page language="java" import="java.sql.*"%> 
<%@ page import="java.lang.*"%> 
<jsp:useBean id="connD" scope="page" class="bean.conn"/> 
<%! 
ResultSet rs=null; 
ResultSet rsTmp=null; 
String sql=""; 
int PageSize=6; 
int Page=3; 
int totalPage=1; 
String str=""; public String ShowOnePage(ResultSet rs,int Page,int PageSize){ 
str=""; 
try{ 
rs.absolute((Page-1)*PageSize+1); 

catch(SQLException e){ 

for(int iPage=1;iPage<=PageSize;iPage++){ 
str+=RsToGbook(rs); 
try{ 
if(!rs.next()) break; 

catch(Exception e){} 

return str; 
} public String RsToGbook(ResultSet rs){ 
String tt=""; 
try{ 
tt+="<tr>"; 
tt+="<td>"+rs.getInt(1)+"</td>"; 
tt+="<td>"+rs.getString(2)+"</td>"; 
tt+="<td>"+rs.getString(3)+"</td>"; 
tt+="<td>"+rs.getInt(4)+"</td>"; 
tt+="</tr>"; 

catch(SQLException e){} 
return tt; 

%> 
<% 
sql="select * from Stu"; 
try{ 
rs=connD.executeQuery(sql); 

catch(Exception e){ 
out.println("访问数据库出错"); 

%> 
<html> 
<head> 
<title>分页浏览数据库技巧</title> 
</head> 
<body bgcolor="#FFFFFF"> 
<h2 align="center">JSP中的分页控制</h2> 
<hr> 
<center> 
<table border> 
<tr bgcolor=lightblue> 
<th>学号</th> 
<th>姓名</th> 
<th>性别</th> 
<th>年龄</th> 
</tr> 
<% 
rsTmp=connD.executeQuery("select count(*) as mycount from Stu"); 
rsTmp.next(); 
int totalrecord=rsTmp.getInt("mycount"); 
if(totalrecord%PageSize==0) 
totalPage=totalrecord/PageSize; 
else totalPage=(int)Math.floor(totalrecord/PageSize)+1; 
if(totalPage==0) 
totalPage=1; 
rsTmp.close(); 
try{ 
if(request.getParameter("Page")==null||request.getParameter("Page").equals("")) 
Page=1; 
else 
Page=Integer.parseInt(request.getParameter("Page")); 

catch(NumberFormatException e){ 
page=1; 

if(Page<1) 
Page=1; 
if(Page>totalPage) 
Page=totalPage; 
out.println(ShowOnePage(rs,Page,PageSize)); 
%> 
</table> 
<form Action="pagev.jsp" Method="GET"> 
<% 
if(Page!=1){%> 
<A HREF="pagev.jsp? Page=1">第一页</A> 
<A HREF="pagev.jsp? Page=<%=Page-1%>">上一页</A> 
<% } 
if(Page!=totalPage){%> 
<A HREF="pagev.jsp? Page=<%=Page+1%>">下一页</A> 
<A HREF="pagev.jsp? Page=<%=totalPage%>">最后一页</A> 
<%} 
rs.close(); 
%> 
<p>输入页数:<input TYPE="TEXT" Name="Page" SIZE="3">页数:<font color="red"><%=Page %>/<%=totalPage%></font> 
</p> 
</form> 
</center> 
<hr> 
</body> 
</html> 
为什么在输入页数里可以滚动 而上一页 下一页这些都不好使啊 那位高手帮忙看看啊 谢谢