title: com.ibm.db2.jcc.am.SqlException: [jcc][t4][10120][10898][4.19.49] Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null
body: <p>In our Struts2 application For Fetching data we got <strong>result set is closed</strong>. we are using one structure for fetching resulset data. We are using <strong>BaseResultSetHandler</strong> fetch resulset data in DAO file.I am not able to find cause why resultset is closed. In the below i have mention code kindly help us </p>
  
  <p>we are having BaseResultSetHandler abstract class</p>
  
  <pre><code>public abstract class BaseResultSetHandler {
      protected ResultSet resultSet;
      public abstract Object handleResult() throws SQLException;
  
      public Object handleResultSet(ResultSet rs) throws SQLException{
          setResultSet(rs);
          Object obj = handleResult();
          return obj;
      }
      public void setResultSet(ResultSet resultSet) {
          this.resultSet = resultSet;
      }
      public ResultSet getResultSet() {
          return resultSet;
      }
      public Integer getInteger(String columnName,ResultSet resultSet) throws SQLException{
          return StringUtility.getInt(resultSet.getInt(columnName));
      }
      public String getString(String columnName,ResultSet resultSet) throws SQLException{
          return StringUtility.getString(resultSet.getString(columnName));
      }
      public String getString(String columnName) throws SQLException{
          return StringUtility.getString(resultSet.getString(columnName));
      }
    }
  </code></pre>
  
  <p>We have one DatabaseManger class For handling database operation in that we have function for fetch data from database</p>
  
  <pre><code>  protected Object executePreparedQuery(String query, List arguments, BaseResultSetHandler BaseResultSetHandler, Connection useThisConnection)
          throws SQLException, InstantiationException, Exception, Throwable
        {
              ResultSet resultSet = null;
          try {
            if (ReferenceCheckUtlity.isNull(useThisConnection)) {
                this.connection = getConnection();
            }else{
                this.connection = useThisConnection;
            }
            this.preparedStatement = this.connection.prepareStatement(query);
  
            if (arguments != null) {
                  Iterator argumentsIterator = arguments.iterator();
                  int index = 1;
                  while (argumentsIterator.hasNext()) {
                       this.preparedStatement.setObject(index++, argumentsIterator.next());
              }
            }
            resultSet = this.preparedStatement.executeQuery();
            Object localObject2 =   BaseResultSetHandler.handleResultSet(resultSet);
  
          } finally {
              if(resultSet!=null){
                  resultSet.close();
              }
              if(this.statement!=null){
                   this.statement.close();
              }
              if(this.preparedStatement!=null){
                   this.preparedStatement.close();
              }
              if(this.connection!=null){
                  this.connection.close();
              }
          }
          return localObject2;
        }
  </code></pre>
  
  <p>In DAO File i have share only 2 method here there are lot of method in file approximate 25+ classes using <strong>BaseResultSetHandler</strong> </p>
  
  <pre><code> public String getCheckId(String Id) throws NumberFormatException, SQLException, InstantiationException, Exception, Throwable  {
      ArrayList&lt;Object&gt; argumentList=new ArrayList&lt;Object&gt;();
      argumentList.add(Id);
      int cnt=Integer.parseInt(""+executePreparedQuery(getCheckIdSql(), argumentList, new getCheckIdHandler(), null));
      if(cnt==0){
          return "N";
      }else{
          return "Y";
      }
  }
         private String getCheckIdSql() {
      StringBuffer query=new StringBuffer();
      query.append("select count(1) as cnt from EMPLOYEES where ID=? for read only ");
      return query.toString();
  }
  
  class getCheckIdHandler extends BaseResultSetHandler {
      @Override
      public Object handleResult() throws SQLException {
          int cnt=0;
          while(resultSet.next()){
              cnt=getInteger("cnt");
          }
          return cnt;
      }
  }   
  public HashMap&lt;String,String&gt; getMajorData() throws InstantiationException, SQLException, Exception, Throwable{
      LinkedHashMap&lt;String,String&gt; list = new LinkedHashMap&lt;String,String&gt;();
      list=(LinkedHashMap&lt;String, String&gt;) executePreparedQuery(getMajorDataSql(), null, new getMajorDataHandler(), null);
      return list;
  
  }
  private String getMajorDataSql() {
      StringBuffer query=new StringBuffer();
      query.append("select RMH_ode,MH_Name from RECMH order by MH_NM for read only");
      return query.toString();
  }
  class getMajorDataHandler extends BaseResultSetHandler {
      @Override
      public Object handleResult() throws SQLException {
          LinkedHashMap&lt;String,String&gt; list = new LinkedHashMap&lt;String,String&gt;();
          while(resultSet.next()){
              String RMH_CD=resultSet.getString("RMH_CD");
              String MH_NM=resultSet.getString("MH_Name");
              list.put(RMH_CD+"*"+MH_Name, RMH_CD+"-"+MH_Name);
          }
          return list;
      }
  }   
  </code></pre>
  
  <p>And I have to also know it is sharing <strong>BaseResultSetHandler</strong>  resultSet Object </p>