标题:structs 登录connection报空指针
只看楼主
zyxnlbh
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-10-17
 问题点数:0 回复次数:4 
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.(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)

Structs.rar (1.17 MB)
搜索更多相关主题的帖子: connection structs 指针 登录 
2008-10-17 12:18
huwangvs
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:34
帖 子:764
专家分:0
注 册:2007-2-4
得分:0 
WorkBean.isLogin里面
try {

                con2.close();

            } catch (SQLException e) {

                e.printStackTrace();

            }

加个判断。
try {
if(con2!=null){
                con2.close();
}
            } catch (SQLException e) {

                e.printStackTrace();

            }
2008-10-17 12:33
zyxnlbh
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-10-17
得分:0 
谢谢你不过刚才我自己解决了
DriverManager.getConnection("jdbc:mysql://localhost:3306/users", "root", "123");
改为:
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/users", "root", "123");
2008-10-17 14:17
yjtvijiavj
Rank: 1
等 级:新手上路
威 望:2
帖 子:19
专家分:0
注 册:2008-10-18
得分:0 
怎么那么多人喜欢用mysql数据库 而且密码都喜欢123 看来以后要试数据库密码先试下123
2008-10-18 21:12
恋轩念伊人
Rank: 5Rank: 5
来 自:湖南衡阳
等 级:贵宾
威 望:19
帖 子:643
专家分:0
注 册:2008-2-23
得分:0 

我不是一个随便的人,我随便起来不是人我哦。信不?
2008-10-20 19:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-238809-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.476859 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved