structs 登录connection报空指针
运行后报以下错误:连接成功!
2008-10-17 11:58:06 org.apache.struts.action.RequestProcessor processException
警告: Unhandled Exception thrown: class java.lang.NullPointerException
2008-10-17 11:58:06 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.NullPointerException
at com.index.bean.WorkBean.isLogin(WorkBean.java:38)
at com.index.struts.action.LoginAction.execute(LoginAction.java:48)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
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:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
搜索更多相关主题的帖子:
connection structs 指针 登录
----------------解决方案--------------------------------------------------------
WorkBean.isLogin里面
try {
con2.close();
} catch (SQLException e) {
e.printStackTrace();
}
加个判断。
try {
if(con2!=null){
con2.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
----------------解决方案--------------------------------------------------------
谢谢你不过刚才我自己解决了
DriverManager.getConnection("jdbc:mysql://localhost:3306/users", "root", "123");
改为:
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/users", "root", "123");
----------------解决方案--------------------------------------------------------
怎么那么多人喜欢用mysql数据库 而且密码都喜欢123 看来以后要试数据库密码先试下123
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------