private void SaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveActionPerformed
if(jTextArea1.getText()!=null || jTextArea1.getText()==" ") {
       if(jTextField1.getText()!=null || jTextField1.getText()==" "){

    try {
        QType_ID = 3;
        
        sql = "INSERT INTO question (QType_ID) VALUES("+QType_ID+")";
        
         int key = 0;
            /////////////// INSERT THE QUESTION & Get the last id that was inserted for the question ////////////////
            connectDb();
            PreparedStatement pstmt = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
            pstmt.executeUpdate();
            ResultSet keys = pstmt.getGeneratedKeys();
            keys.next();
            key = keys.getInt(1);

        
        instructions = jTextArea1.getText();
        noofwords=  Integer.parseInt(jTextField1.getText());

        sql1 = "INSERT INTO essay (noofwords,instructions,QType_ID,Question_ID) VALUES(' "+noofwords+"', '"+instructions+"', 3,' " + key + "')";
        int rows = st.executeUpdate(sql1);
        if (rows > 0) {
            JOptionPane.showMessageDialog(this, "Question is saved successfully!");
        }
        
        System.out.println(sql1);
        
    } catch (Exception exc) {
            exc.printStackTrace();
        }
        


}
else
    JOptionPane.showMessageDialog(null, "you have to add the number of words!"); }
 
 else
     JOptionPane.showMessageDialog(null, "you have to add instructions!");

        
    }//GEN-LAST:event_SaveActionPerformed