新手提问,运行时提示
NullPointerException,不晓得错在哪,请有空的进来看看.
代码如下,在执行到 stmt.executeUpdate()的时候报错
public class UserOperation extends Action{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
GdzczjForm searchForm = (GdzczjForm) form;
String czry_dm=searchForm.getczry_dm();
String sjjkxybz=searchForm.getsjjkxybz();
String sjjkqx=searchForm.getsjjkqx();
String pwd=searchForm.getpwd();
Connection conn = null; //定义连接
String sql = null; //定义SQL语句
PreparedStatement stmt=null;
try {
conn = Database.getConn(); //得到连接
sql = "update dm_czry set sjjkxybz=?,sjjkqx=?,sjjkpwd=? where czry_dm=? ";
stmt = conn.prepareStatement(sql);
stmt.setString(1,sjjkxybz);
stmt.setString(2,sjjkqx);
stmt.setString(3,pwd);
stmt.setString(4,czry_dm);
stmt.executeUpdate();//运行到这里就出错了
stmt.close();
} catch(
SQLException e) {
e.printStackTrace();
return mapping.findForward( "faild ");
} finally{
if(stmt!=null) try{stmt.close();}
catch(SQLException ignore){}
if(conn!=null) try{conn.close();}
catch(SQLException ignore){}
}
return mapping.findForward( "success ");
}
}
错误提示如下
Error 500--Internal Server Error
java.lang.NullPointerException at jsp_servlet.__useroperation._jspService(__useroperation.java:190)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:322)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)