title: What if ResultSet that is to be retrieved from database does not exist. how can i make the command issue a JOptionPane message in JDBC
body: <p>I would like to Know What if once the search button in clicked and the ID does not exist, where do i imput the Command to display a error..</p>
  
  <pre><code>else if(e.getSource() == btnSearch) {
    ResultSet rs = null;           
    rs = sD.getSummonID(txtSummonID.getText());
    Summon s = null;
    try {
      while(rs.next()) {
        s = new Summon(rs.getInt("id"), rs.getString("plateNum"), 
            rs.getDouble("amount"), rs.getString("recDate"), 
            rs.getString("location"), rs.getString("officer")); 
      }
  
      txtcarLicenceNo.setText(s.getCarLicenceNo());
      txtAmount.setText(Double.toString(s.getAmount()));
      txtLocation.setText(s.getLocation());
      txtOfficer.setText(s.getOfficerInCharge());                       
    } catch (SQLException ex) {
      System.err.println("SQL Exception: " + ex);
    }
  }
  </code></pre>
  
  <p>the other class looks like this </p>
  
  <pre><code>public ResultSet getSummonID(String summonID) {
    getConnection();
    try {
      stmt = conn.createStatement();
      rs = stmt.executeQuery("SELECT * FROM record WHERE id = " + summonID);                 
  
      return rs;
    } catch (SQLException e) {
      System.err.println("SQL Exception: " + e);
      return rs;
    }
  }
  </code></pre>