你的分给的太少
去这吧
http://www.12Yeah.com/default2.htm?user=abcd

解决方案 »

  1.   

    这个是我想应用的分页代码,但是也出现了这个问题
    谢谢<jsp:useBean id="search_info" scope="page" class="pack.dbconn" />
    <%
    int intPageSize; //一页显示的记录数 
    int intRowCount; //记录总数 
    int intPageCount; //总页数 
    int intPage; //待显示页码 int i,j,k; //设置一页显示的记录数 
    intPageSize = 3; //取得待显示页码 
    String strPage = request.getParameter("page"); if(strPage==null){//表明在QueryString中没有page这一个参数,此时显示第一页数据 
    intPage = 1; 
    }
     else
    {
    //将字符串转换成整型 
    intPage=Integer.parseInt(strPage);
    if(intPage<1) intPage = 1; 
    }%>
    <%
       String username=new String(request.getParameter("username").getBytes("8859_1"));
       String strSQL="select count(*) as cnt from user_info where user_name like '%"+username+"%'";
       ResultSet sqlRst=search_info.executeQuery(strSQL);//执行SQL语句并取得结果集 
    sqlRst.next(); //记录集刚打开的时候,指针位于第一条记录之前 
    intRowCount = sqlRst.getInt(1); 
    sqlRst.close(); //关闭结果集 
    //记算总页数 
    intPageCount = (intRowCount+intPageSize-1) / intPageSize; 
    //调整待显示的页码 if(intPage>intPageCount) intPage = intPageCount; 
    //设置获取数据SQL语句 
      String sql ="select * from user_info where user_name like '%"+username+"%'";
    //执行SQL语句并取得结果集 
      ResultSet rs = search_info.executeQuery(sql);
    //将记录指针定位到待显示页的第一条记录上 
    i = (intPage-1) * intPageSize; 
    for(j=0;j<i;j++) rs.next(); %> <html> 
    <head>
    <title>分页</title>
    /head> 
    <body> <p align=center>jdbc-odbc留言版</p> <table border="1" cellspacing="0" cellpadding="0" width=600 align=center> <% 
    //显示数据 
    i = 0; 
    while(i<intPageSize && rs.next())

    String name=rs.getString("user_name");
    String dept=rs.getString("user_dept");
    String email=rs.getString("user_email");
    %> 
    <tr> 
    <td>姓名:<%=name%></td>
    \,td>邮件:<%=email%></td>
    </tr> 
    <tr> 
    <td colspan=2><%=dept%></td>
    </tr>
    <% i++; } %>
    <tr> 
    <td colspan=2 align=center> 
    第<%=intPage%>页  共<%=intPageCount%>页  
    <%if(intPage<intPageCount){%>
    <a href="search_ok.jsp?page=<%=intPage+1%>">下一页</a><%
    }
    %>  <%
    if(intPage>1)
    {
    %>
    <a href="search_ok.jsp?page=<%=intPage-1%>">上一页</a>
    <% } %>
    </td> 
    </tr>
    </table> </body> 
    </html> 
    <% 
    //关闭结果集 
    rs.close(); 
    //关闭数据库
    search_info.close();
    %>
      

  2.   

    你要注意
    1.String username=new String(request.getParameter("username").getBytes("8859_1"));
    你要确保有username对象传值过来,如果没有,会出现这个错误。
    2.
    //执行SQL语句并取得结果集 
    sqlRst.next(); //记录集刚打开的时候,指针位于第一条记录之前 
    intRowCount = sqlRst.getInt(1); 
    sqlRst.close(); //关闭结果集 此处最好写为
    while(sqlRst.next()){
      intRowCount=sqlRst.getInt(1);
    }
    sqlRst.close()这一句最好先注释起来,查明错误后在加上3.String name=rs.getString("user_name");
    String dept=rs.getString("user_dept");
    String email=rs.getString("user_email");
    取记录时,一定要保证你取记录的顺序是和数据库中字段的保存顺序是一样的其它的,我也看不出来了,因为也不知道你的bean写的对不对,关键是数据库,也不知道是怎么样的,最好可以打包给我[email protected]
      

  3.   

    奇怪的是,我查寻能找出查询的结果....但点 "下一页 "  就会出现如上错误,
    难道page参数传递有问题??