还有这里的分
http://community.csdn.net/Expert/topic/3320/3320866.xml?temp=.5787165

解决方案 »

  1.   

    <%
    int page=1;
    String sql="select * from images where partake='"+page+"'";
    %>这样写你试试看.可不可以.
      

  2.   

    String p=new Integer(page).toString();
    String sql="select * from images where partake="+p;
      

  3.   

    <%@    page    contentType="text/html;charset=gb2312"%>    
    <%@    page    import="java.sql.*"%><%
    String PageRecordString=request.getParameter("PageRecord");
    String PageIDString=request.getParameter("PageID");int PageRecordInt=Integer.parseInt(PageRecordString);
    int PageIDInt=Integer.parseInt(PageIDString);if(PageRecordInt<=0)PageRecordInt=1;
    if(PageIDInt<=0)PageIDInt=1;int ScreenOutInt=(PageIDInt-1)*PageRecordInt;String PageRecord=new Integer(PageRecordInt).toString();
    String PageID=new Integer(PageIDInt).toString();
    String ScreenOut=new Integer(ScreenOutInt).toString();
    %><%Class.forName("org.gjt.mm.mysql.Driver").newInstance();    
    String    url    ="jdbc:mysql://127.0.0.1:3306/photo?user=root&password=123456";
                      
    //testDB为你的数据库名    
    Connection    conn=    DriverManager.getConnection(url);    
    Statement    stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);String sql = "select * from images where partake=1 limit "+ScreenOut+","+PageRecord;ResultSet    rs=stmt.executeQuery(sql);    
    while(rs.next())    {%>    
    您的第1个字段内容为:<%=rs.getString(1)%><br>
    <%}%>    
    <%out.print("数据库操作成功,恭喜你");%>    
    <%rs.close();    
    stmt.close();    
    conn.close();    
    %>
    还是出错,错误信息为
    500 Servlet Exceptionjava.lang.NumberFormatException: null
    at java.lang.Integer.parseInt(Integer.java:436)
    at java.lang.Integer.parseInt(Integer.java:518)
    at _jsp._index__jsp._jspService(/index.jsp:8)
    at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
    at com.caucho.jsp.Page.pageservice(Page.java:571)
    at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:155)
    at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:190)
    at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:177)
    at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:221)
    at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:263)
    at com.caucho.server.port.TcpConnection.run(TcpConnection.java:331)
    at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:464)
    at com.caucho.util.ThreadPool.run(ThreadPool.java:408)
    at java.lang.Thread.run(Thread.java:534)
    Resin-3.0.8 (built Tue, 08 Jun 2004 02:25:40 PDT)
      

  4.   

    要看你的partake类型了,不是数字用
    String p=new Integer(page).toString();
    String sql="select * from images where partake='"+p+"'";
      

  5.   

    你意思是说该成这样String sql = "select * from images where partake=1 limit '"+ScreenOut+"','"+PageRecord+"'";可这样一样出错啊,错误信息和上面一样我现在重启一下,等会回来
      

  6.   

    可能是这里有问题int PageRecordInt=Integer.parseInt(PageRecordString);
    int PageIDInt=Integer.parseInt(PageIDString);其中 PageRecordString 或者 PageIDString 为 null
    你可以改成 下面的代码 试试
    int PageRecordInt;
    try {
        PageRecordInt=Integer.parseInt(PageRecordString);
    } catch (NumberFormatException e) {
        PageRecordInt = 0;
    }
    int PageIDInt=Int;
    try {
        PageIDInt=Integer.parseInt(PageIDString);
    } catch (NumberFormatException e) {
        PageIDInt = 0;
    }
      

  7.   

    String sql = "select * from images where partake='"+page+"'";你的数据库里,如果 partake 字段是整型或者其它数值型的,就不要加单引号,直接加 page 就可以了
      

  8.   

    java.lang.NumberFormatException: null
    错误原因为程序中出现了空值,看看你自己的程序中变量的赋值可能有问题
      

  9.   

    你把PageRecordInt和PageIDInt两个变量的值打出来看看,可能有空值
      

  10.   

    String sql = "select * from images where partake="+page; 去掉单引号看看
      

  11.   

    字符串为null的时候你怎么可以转化成int呢?
      

  12.   

    int page=1;
    String sql = "select * from images where partake='"+page+"'";
    变为
    String sql = "select * from images where partake='"+((Integer)page.toString())+"'";
      

  13.   

    ((Integer)page.toString())  估计不行吧应该是 String.valueOf(page) 呀
      

  14.   

    我知道问题的症结了,感谢treeroot(根根)。(真是一语道破玄机啊!!)
      

  15.   

    jamesfancy()边城狂人(James Fancy)你的分我在其它页面给你!!