日期:2014-05-17  浏览次数:20690 次

求教!修改表单信息某一列值出现NullPointerException报错
这是报错内容:
org.apache.jasper.JasperException: An exception occurred processing JSP page /update_cooperations.jsp at line 47

44: <input type="hidden" name="p_number" value="<%=rs_1.getString("number")%>" /> <% }else {%>
45: <input type="hidden" name="p_number" value=" " /> <%} %></th>
46: <th scope="col">
47: <input type="text" name="suppliername" value="<%=rs.getString("suppliername")%>" />
48: &nbsp;
49: <% String sql_2="select ICP from supplier where material ='"+request.getParameter("material")+"' and name = '"+request.getParameter("suppliername")+"'";
50: ResultSet rs_2 = statement.executeQuery(sql_2);%>


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
com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:966)
com.mysql.jdbc.ResultSet.getString(ResultSet.java:5584)
org.apache.jsp.update_005fcooperations_jsp._jspService(update_005fcooperations_jsp.java:122)
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)

这是我的源代码(菜鸟,莫见笑~!):
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url= "jdbc:mysql://localhost:3306/graduationproject?user=root&password=123&useUnicode=true&characterEncoding=GB2312";
Connection connection=DriverManager.getConnection(url); 
Statement statement = connection.createStatement();
String number=request.getParameter("number");
String sql="select * from cooperations where number='"+number+"'";
ResultSet rs = statement.executeQuery(sql);
while(rs.next()) {
%>
<form id="form1" name="form1" method="post" action="deal_update_cooperation.jsp">
  <table width="200">
  <tr>
  <th sco