啊?
这是你程序的问题,和你使用数据源没有关系。
问题出在在 你的记录集关闭之后,你还使用它取数据;
检查你是不是不小心关闭了连接,或者rs,然后还使用rs.getString("...");之类的

解决方案 »

  1.   

    但是,为什么我换成用直接用URL连接数据库,就不会存在这个问题。看看  private Connection getConnection() throws NamingException, SQLException {
       try {
          Class.forName("com.mysql.jdbc.Driver");
          return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/smgp_6789", "smspf","iamroot");
        } catch (Exception ex) {
          System.err.println(" * Error: get DB connection error. Ex. msg: " + ex);        ex.printStackTrace();      return null;
        }  }
    *************************************************************************************
    //      protected Connection createConnection() throws NamingException, SQLException
    //    {
    //
    //        Context ctx = new InitialContext();
    //        DataSource ds = (DataSource)ctx.lookup(DATASOURCE_NAME);
    //
    //        System.out.println("***********************************\nbegin get ds conn\n****************");
    //        return ds.getConnection();
    //    }
    上面两个,我用第一个getConnection(),不会存在关闭rs得问题。而用了createConnection(),就发生了