在JSP系统中对ResultSet方法的调用总是报错 5
org.apache.jasper.JasperException:AnexceptionoccurredprocessingJSPpage/first.jspatlin...
org.apache.jasper.JasperException: An exception occurred processing JSP page /first.jsp at line 28
25: <%
26: ResultSet rs = goods.showGoods();
27: int i = 0;
28: while(rs.next() && i<10)
29: {
30: String strSql1 = "select name from goodsField where ID ='"+rs.getLong("goodsField")+"'";
31: String strSql2 = "select * from users where ID ='"+rs.getLong("issuer")+"'";
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NullPointerException
org.apache.jsp.first_jsp._jspService(first_jsp.java:109)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 展开
25: <%
26: ResultSet rs = goods.showGoods();
27: int i = 0;
28: while(rs.next() && i<10)
29: {
30: String strSql1 = "select name from goodsField where ID ='"+rs.getLong("goodsField")+"'";
31: String strSql2 = "select * from users where ID ='"+rs.getLong("issuer")+"'";
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NullPointerException
org.apache.jsp.first_jsp._jspService(first_jsp.java:109)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 展开
3个回答
展开全部
NullPointerException
空指针使用异常,也就说你用了一个为空的引用变量.
照第一部分来看是你连接数据库时出现了问题,所以返回了一个Null的空引用.也就是你的网络没连上数据库.
goods.ShowGoods()调用的时侯出了问题.你查查.
你也可以看看rs是不是一个Null引用,你在下面加一句:if(rs==Null) System.out.println("rs is Null");就可以了.但不管怎样肯定是goods.ShowGoods()出了问题造成以下的.
空指针使用异常,也就说你用了一个为空的引用变量.
照第一部分来看是你连接数据库时出现了问题,所以返回了一个Null的空引用.也就是你的网络没连上数据库.
goods.ShowGoods()调用的时侯出了问题.你查查.
你也可以看看rs是不是一个Null引用,你在下面加一句:if(rs==Null) System.out.println("rs is Null");就可以了.但不管怎样肯定是goods.ShowGoods()出了问题造成以下的.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询