private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
        try {

            messageLabel.setText("");
            Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "oracle");
            Statement s = con.createStatement();
            String Name = name.getText();
            String IATA = iata.getText();

            if (Name.equals("Airline Name") || IATA.equals("IATA Code")) {
                messageLabel.setText("All fields are mandatory!");
                con.close();
                return;
            }

            ResultSet rs = s.executeQuery("select alname,al_iata from airline");
            while (rs.next()) {
                if (rs.getString(1).equals(Name) || rs.getString(2).equals(IATA)) {
                    messageLabel.setText("Airline already exists!");
                    con.close();
                    return;
                }
            }

            s.executeUpdate("insert into airline values(airline_id.nextval,'" + Name + "','" + IATA + "')");
            iata.setText("IATA Code");
            name.setText("Airline Name");
            cancelButton.setVisible(true);
            javax.swing.JOptionPane.showMessageDialog(this, "Entered");
            con.close();

        } catch (SQLException se) {
            System.out.println(se);
             javax.swing.JOptionPane.showMessageDialog(this, "Airline name -max 40\nAirline IATA -max 2characters");
            cancelButton.setVisible(true);
        }

    }//GEN-LAST:event_okActionPerformed