db2数据库抛错:Result set already closed

使用weblogic在oracle跑得好好的代码,放到db2上抛了这个错误:

       2015-11-09 15:04:38: [ERROR]( Log.java,115 ) - Result set already closedjava.sql.SQLException: Result set already closed
at weblogic.jdbc.wrapper.ResultSet.checkResultSet(ResultSet.java:110)
at weblogic.jdbc.wrapper.ResultSet.preInvocationHandler(ResultSet.java:65)
at weblogic.jdbc.wrapper.ResultSet_weblogic_jdbcx_base_BaseResultSetWrapper.next(Unknown Source)

       代码如下:

       

Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
      conn = getConnection();
      // 关闭自动提交
      conn.setAutoCommit(false);
      System.out.println("ssss" + conn.isClosed());
      System.out.println("*****" + sql);
      ps = conn.prepareStatement(sql);
      rs = ps.executeQuery();
      // 提交
      System.out.println("55555" + conn.isClosed());
      conn.commit();
      System.out.println("rrr" + conn.isClosed());
      // 转换数据
      List result = new ArrayList();
      Map map = null;
      for (; rs.next(); result.add(map))
        map = getHashMapByResultset(rs);
      return result;
    } finally {
      if (rs != null) {
        rs.close();
        rs = null;
      }
      if (ps != null) {
        ps.close();
        ps = null;
      }
      if (conn != null) {
        conn.close();
      }
    }

       解决方法:db2数据库驱动版本不正确。

你可能感兴趣的:(数据库,exception,代码,weblogic,db2)