Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 不定期的null pointer exception
king_wjb





发贴: 27
积分: 0
于 2007-01-26 15:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我用的是oracle数据库,通过连接池连接,在运行的过程中经常出现null pointer exception,而且不一定是在哪个类以及哪个方法中,例如如下代码:

public static int executeSqlReturnCount(String sql) throws Exception {
    if (log.isDebugEnabled()) {
      log.debug("sql:" + sql);
    }
    Statement stmt;
    Connection conn;
    // 获取数据库连接
    conn = ConnectDB.getDBConnection();
    // 创建Statement对象
    stmt = conn.createStatement(); //这一行经常会出现null pointer exception
    // 执行SQL语句并将查询结果放入结果集中
    ResultSet rs = stmt.executeQuery(sql);
    // 将结果集中的数据取出放入User类的对象中
    if (log.isDebugEnabled()) {
      log.debug("sql over");
    }
    int result = 0;
    if (rs.next()) {
      result = rs.getInt(1);
    }
    DBUtil.closeResultSet(rs);
    DBUtil.closeStatement(stmt);
    ConnectDB.freeDBConnection(conn);
    return result;
  }

我怀疑是连接未正常释放,但是查了所有的类中的方法,都有ConnectDB.freeDBConnection(conn);
我找不出原因,请各位帮忙看看,谢谢!




话题树型展开
人气 标题 作者 字数 发贴时间
10533 不定期的null pointer exception king_wjb 835 2007-01-26 15:53
8303 Re:不定期的null pointer exception 九佰 239 2007-01-26 20:19
9132 Re:不定期的null pointer exception king_wjb 59 2007-01-29 12:01

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923