title: Operation not allowed after ResultSet closed error
body: <p>I have a code which is inserting data into table after processing but again and again I am getting error </p>
  
  <blockquote>
    <p>Operation not allowed after ResultSet closed</p>
  </blockquote>
  
  <p>Here is my code.</p>
  
  <pre><code> try {
          Connection con = null;
          Class.forName("com.mysql.jdbc.Driver");
          con = DriverManager.getConnection(
                  "jdbc:mysql://localhost:3306/asteriskcdrdb", "root", "techsoft");
          Statement st = con.createStatement();
          ResultSet rs = st.executeQuery("Select * from asteriskcdrdb.sp1");
          while (rs.next()) {
              AreaCode = rs.getString("AreaCode");
              //System.out.println(AreaCode);
              String Pulse = rs.getString("Pulse");
              Rate = rs.getInt("Rate/pulse");
              // System.out.println(Rate);
              if (AreaCode.equals(str)) {
                  System.out.println("Hii");
                  try {
                      Connection conn = null;
                      Class.forName("com.mysql.jdbc.Driver");
                      conn = DriverManager.getConnection(
                              "jdbc:mysql://localhost:3306/asteriskcdrdb", "root", "techsoft");
                      Statement stmt = conn.createStatement();
                      rst = stmt.executeQuery("Select * from cdr where src ='9035020090'");
                      while (rst.next()) {
                          calldate = rst.getString("calldate");
                          // System.out.println(calldate);
                          clid = rst.getString("clid");
                          src = rst.getString("src");
                          dst = rst.getString("dst");
                          dcontext = rst.getString("dcontext");
                          channel = rst.getString("channel");
                          dstchannel = rst.getString("dstchannel");
                          lastapp = rst.getString("lastapp");
                          lastdata = rst.getString("lastdata");
                          duration = rst.getString("duration");
                          //System.out.println(duration);
                          dur = Integer.parseInt(duration);
                          //System.out.println(dur);
                          data.add(dur);
                          billsec = rst.getString("billsec");
                          disposition = rst.getString("disposition");
                          amaflags = rst.getString("amaflags");
                          accountcode = rst.getString("accountcode");
                          uniqueid = rst.getString("uniqueid");
                          userfield = rst.getString("userfield");
                          int newcost = checktime(dur, Rate);
                          stmt.executeUpdate("insert into cdrcost (
           calldate,clid,src,dst,dcontext,channel,
           dstchannel,lastapp, lastdata,duration,billsec,
           disposition,amaflags,accountcode,uniqueid,
           userfield,cdrcost) values ('" + calldate + "','" + 
           clid + "','" + src + "','" + dst + "','" + dcontext 
           + "','" + channel + "','" + dstchannel + "','" + 
           lastapp + "','" + lastdata + "','" + duration + "','" + 
           billsec + "','" + disposition + "','" + amaflags 
            + "','" + accountcode + "','" + uniqueid + "','" + userfield  
           + "','" + newcost + "')");
                       }
  
                  } catch (Exception e) {
                      System.out.println(e);
                  }
              } else if (AreaCode.equals(str2)) {
                  System.out.println("Hii2");
              }
          }
  
      } catch (Exception e) {
          System.out.println(e);
      }
  }
  
  public static int checktime(int dur, int Rate) {
      int cost = 0;
  
      // System.out.println(c);
      int min = 60;
  
      int quotient = dur / min;
      // System.out.println(quotient);
  
      int reminder = dur % min;
      //  System.out.println(reminder);
  
      if (reminder &gt; 0) {
          quotient = quotient + 1;
          // System.out.println(quotient);
  
          // System.out.println(cost);
      }
      cost = quotient * Rate;
      return cost;
  }
  </code></pre>