SQLException: ten zestaw wyników jest zamknięty

Próbuję porównać wartości z trzechResultset, ale wydaje się, że wyjątek jest taki, że próbuję go uruchomić. Czy ktoś może mi pomóc, gdzie się nie uda. Będę wdzięczny za każdą pomoc. Oto fragment kodu, który zgłasza błąd:

<code>    java.sql.Connection connDB = null;

    java.lang.Object[] reconciledPaymentDetails = null;

    java.util.Vector shiftsVector = new java.util.Vector(1, 1);

    String status = "";

    try {

        Class.forName("org.postgresql.Driver");
        } 
    catch (ClassNotFoundException ex) {
        Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
       }
    try {
        connDB = DriverManager.getConnection("jdbc:postgresql://" + hostName + ":" + portNumber 
        + "/" + dbName, userName, password);

       System.out.println("Connection established : [" + connDB.toString() + "]");

       java.sql.Statement pstmt = connDB.createStatement();

       java.sql.Statement pstmtShifts = connDB.createStatement();

       java.sql.ResultSet rset = pstmt.executeQuery("SELECT DISTINCT payment_mode,  
       transaction_type, credit FROM ac_cash_collection WHERE shift_no = '" + shiftNumber + 
       "'");

    while (rset.next()) {
       java.sql.ResultSet rsetShifts = pstmtShifts.executeQuery("SELECT DISTINCT amount, 
       shift_amount FROM ac_shift_collections WHERE shift_no = '" + shiftNumber + "' AND 
       pay_mode ilike '"+rset.getString(1) +"'");

          while (rsetShifts.next()) {

            java.sql.ResultSet rset2 = pstmt.executeQuery("select debit from ac_cash_book where 
            shift_no='"+shiftNumber+"'");

               while (rset2.next()){
                   double debit =rset2.getDouble("debit");

                    if((rset2.getDouble("debit")<=0 ))

                       status = "no_banked";

                    else if((rset2.getDouble("debit")==rsetShifts.getDouble("amount")) &&  
                         (rsetShifts.getDouble("amount"))< rsetShifts.getDouble("shift_amount"))

                       status= "BntClosed";

                   else if (rset2.getDouble(1)==rsetShifts.getDouble("shift_amount"))

                       Status ="bClosed";

              shiftsVector.addElement(rset.getString(1)+":"+rsetShifts.getString(1)+":"+status);
    } 
   }
  }
</code>

questionAnswers(1)

yourAnswerToTheQuestion