i'm just new to connecting MySql database to my java GUI and i have this problem. In a button I have two query, I want the second query not to run when the first query is not executable.
heres my button action:
private void addActionPerformed(java.awt.event.ActionEvent evt) {                                    
        theQuery("INSERT INTO `deliv`(`prod_code`, `client`, `address`,`quantity`,`delivery_date`,`deliv_code`) VALUES ('"+prodC.getText()+"','"+client.getText()+"','"+address.getText()+"','"+quantity.getText()+"','"+delivdate.getText()+"','"+delivCode.getText()+"')");
        theQuery("Update product_list set prod_stock=prod_stock-'"+quantity.getText()+"'where b.prod_code="+prodC.getText());
        this.setVisible(false);
        new adminLogin().setVisible(true);
    }
and heres my theQuery  to be able to execute the commands:
public void theQuery(String query){
      Connection con = null;
      Statement st = null;
      try{
          con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/dbsystem","root","");
          st = con.createStatement();
          st.executeUpdate(query);
          JOptionPane.showMessageDialog(null,"Success!");
      }catch(Exception ex){
          JOptionPane.showMessageDialog(null,ex.getMessage());
      }
  }
please help me
 
    