title: stop ResultSet from firing pop-ups when database table has no records
body: <p>I have the intention of creating pop-ups when a particular table has records and when there are no records in that table, the pop-ups will stop showing.
  the pop-ups serves as a notification to the user on tasks that has been done(record entries) and when the user confirms he has seen those records, the records will be deleted and the pop-ups wont show until there are records entered into the table again for another confirmation.</p>
  
  <p>I used ScheduledExecutorService to create a runtime for the method where this code must check the ResultSet every 10 seconds for records and if there are no records, the method won't be fired.</p>
  
  <pre><code>try{
      String sql="select * from confirm_purchase";
      pst=con.prepareStatement(sql);
      rs=pst.executeQuery();
      if(rs.first()){
       Runnable runnable = new Runnable() {
           @Override
           public void run() {
               int d2 = JOptionPane.showConfirmDialog(null,"new purchased item(s) have been recorded.\ndo you wish to view them?","view current items purchased",JOptionPane.YES_NO_OPTION);
               if(d2==0){
                   confirmItemPurchase cip = new confirmItemPurchase();
                   cip.setVisible(true);
               }
           }
       };
     ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); 
     service.scheduleAtFixedRate(runnable, 0, 10, TimeUnit.SECONDS); 
      }else{
      System.out.println("no data yet");
      }
  
      }catch(Exception e){
      JOptionPane.showMessageDialog(null,e);
      }finally{
      try{
      rs.close();
      pst.close();
      }
      catch(Exception e){
        }
      }
  </code></pre>
  
  <p>This code works fine and the pop-ups appear. but when the records are cleared in the table, the pop-up still shows up. </p>
  
  <p>How do I stop the pop-up from showing when there are no records in the table.</p>