title: How to stop Java Result: 1 error? Why is that happening?
body: <p>I'm working on java swing on netbeans 8.0. I'm having repeated messages when I run this code.  And finally I commented it. After that System doesn't stop working. Finally I used Task Manager and stop the whole system. Then I'm having Java Result: 1 error. 
  <br/>
  <br/>
  Here is my source code.<br/></p>
  
  <pre><code>public void SaveDamage(JTextField txtItID, JTextField txtInID, JTextField txtQty, JTextField txtTotal) {
      try {
          ResultSet rs1 = JDBC.getData("select inid from damage where inid='" + txtInID.getText() + "'");
          if (rs1.next()) {
              JOptionPane.showMessageDialog(null, "This invoice is already finalized", "Error", JOptionPane.ERROR_MESSAGE);
          } else {
              try {
                  boolean bool = JDBC.putData("insert into damage(itid, qty,total, inid) values('" + txtItID.getText() + "' , '" + txtQty.getText() + "' ,'"+txtTotal.getText()+"' , '" + txtInID.getText() + "')");
                  if (bool) {
                      JOptionPane.showMessageDialog(null, "damaged saved");
                      try {
                          ResultSet rs = JDBC.getData("select avqty from item where itid='" + txtItID.getText() + "' ");
                          while (rs.first()) {
                              int newqty = rs.getInt("avqty") - Integer.valueOf(txtQty.getText());
                              try {
                                  boolean bool1 = JDBC.putData("update item set avqty = '" + newqty + "' where itid = '" + txtItID.getText() + "'  ");
                                  if (bool1) {
                                      // JOptionPane.showMessageDialog(null, txtItID.getText());
                                      //  JOptionPane.showMessageDialog(null, "item updated");
                                  }
                              } catch (Exception e) {
                                  e.printStackTrace();
                              }
                          }
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p><br/>
  <br/>
  This is my JDBC class.
  <br/></p>
  
  <pre><code>package Model;
  //import static Model.JDBC.con;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.Statement;
  import javax.swing.JOptionPane;
  
  public class JDBC {
      static String driver = "com.mysql.jdbc.Driver";
      static String url = "jdbc:mysql://localhost/cat";
      static Connection con;
      static boolean b ;
  
      public  static void setCon() {
          try {
              Class.forName(driver);
              con = DriverManager.getConnection(url, "root", "access456");
          } catch (Exception ex) {
              JOptionPane.showMessageDialog(null, ex);
          }
      }
  
      public static Connection getCon() throws Exception {
          if (con == null) {
              setCon();
          }
          return con;
      }
  
      public static boolean putData(String sql) {
          try {
              PreparedStatement state = getCon().prepareStatement(sql);
              state.executeUpdate();
              b = true;
          } catch (Exception ex) {
              b= false;
              JOptionPane.showMessageDialog(null, ex);
          }
          return b;
      }
  
      public static ResultSet getData(String sql) throws Exception {
          Statement state = JDBC.getCon().createStatement();
          ResultSet rset = state.executeQuery(sql);
          return rset;
      }
  }
  </code></pre>