http://expert.csdn.net/Expert/topic/2003/2003607.xml?temp=.9213373楼主偷了我的分

解决方案 »

  1.   

    出现这种异常一般是你的getter和setter方法中没有对NUll时的处理机制。比如
    java.sql.Date date=ndate;
    有可能ndate本身为空,又传给了date,
    然后不加处理就对date进行如下转换date.toString();结果就是出现空指针异常。
    主要是编写代码不规范和经验欠缺所致。仔细检查你的程序吧!
      

  2.   

    jsp_servlet._test1.__testsql._jspService(__testsql.java:124)
    在jb中生成的文件里面可以打开上面的文件看124行就行了
      

  3.   

    你的代码肯定要出问题。
    1,rs很容易过期。
    2,数据库的善后处理不好。
    给你一个比较保险的。
      //输入:sql语句
      //输出:查询的结果集
      public CachedRowSet executeQuery(String sql) throws java.sql.SQLException {
        CachedRowSet cst = new CachedRowSet();
        try {
          conn = db.getConnection();
          ps = conn.createStatement();
          rs = ps.executeQuery(sql);
          cst.populate(rs);
          rs.close();
        }
        catch (SQLException e) {
          System.out.println(e.getMessage());
        }
        finally {
          db.CleanConnection(conn, ps, rs);
        }
        return cst;//离线结果急(你的问题出在这里,返回的rs不能保存,应该用一个离线的结果急来保存)
      }
      //输入:要执行的sql语句
      //输出:无
      public void execute(String sql)throws SQLException {
        try {
          conn = db.getConnection();
          ps = conn.createStatement();
          ps.execute(sql);
          ps.close();
        }
        catch (SQLException e) {
           throw new SQLException(e.getMessage());
        }
        finally {
          try {
            db.CleanConnection(conn, ps, rs);
          }
          catch (SQLException e) {
            throw new SQLException(e.getMessage());
          }
        }
      }而且应该用finally来善后处理
      

  4.   

    你的代码肯定要出问题。
    1,rs很容易过期。
    2,数据库的善后处理不好。
    给你一个比较保险的。
      //输入:sql语句
      //输出:查询的结果集
      public CachedRowSet executeQuery(String sql) throws java.sql.SQLException {
        CachedRowSet cst = new CachedRowSet();
        try {
          conn = db.getConnection();
          ps = conn.createStatement();
          rs = ps.executeQuery(sql);
          cst.populate(rs);
          rs.close();
        }
        catch (SQLException e) {
          System.out.println(e.getMessage());
        }
        finally {
          db.CleanConnection(conn, ps, rs);
        }
        return cst;//离线结果急(你的问题出在这里,返回的rs不能保存,应该用一个离线的结果急来保存)
      }
      //输入:要执行的sql语句
      //输出:无
      public void execute(String sql)throws SQLException {
        try {
          conn = db.getConnection();
          ps = conn.createStatement();
          ps.execute(sql);
          ps.close();
        }
        catch (SQLException e) {
           throw new SQLException(e.getMessage());
        }
        finally {
          try {
            db.CleanConnection(conn, ps, rs);
          }
          catch (SQLException e) {
            throw new SQLException(e.getMessage());
          }
        }
      }而且应该用finally来善后处理
    估计错误的地方就是