/**
   * @param matrikel
   * @param name
   * @param vorname
   * @param adresse
   * @param srKuerzel
   * @param modul
   * @param semester
   * @return
   * @throws ApplicationException
   */
  @Override
  public boolean announce(
      String matrikel,
      String name,
      String vorname,
      String adresse,
      String srKuerzel,
      Modul modul,
      String semester)
      throws ApplicationException {

    boolean announced = true;
    String sql;
    ResultSet resultSet = null;

    /** Prüfung ob das Modul überhaupt ein Praktikum vorsieht. */
    sql = "SELECT PR" + " FROM MODUL" + " WHERE MKUERZEL = '" + modul.getKuerzel() + "'";

    try {
      resultSet = executeQuery(sql);

      if (resultSet.next() && resultSet.getInt("PR") == 0) {

        throw new ApplicationException("Das Modul sieht kein Praktikum vor");
      }

    } catch (SQLException ex) {

      throw new ApplicationException(ex.getMessage());
    }

    /*
     * Prüfung ob das übergebene Modul nicht Bestandteil der Studienrichtung
     * des anzumeldenden Studenten ist.
     */
    sql =
        "SELECT *"
            + " FROM KATEGORIEUMFANG"
            + " WHERE MKUERZEL = '"
            + modul.getKuerzel()
            + "'"
            + " AND SKUERZEL = '"
            + srKuerzel
            + "'";

    try {
      resultSet = executeQuery(sql);

      if (!resultSet.next()) {

        throw new ApplicationException("Der Student hat dieses Modul nicht belegt.");
      }

    } catch (SQLException ex) {

      throw new ApplicationException(ex.getMessage());
    }

    sql = "SELECT NAME" + " FROM STUDIENRICHTUNG" + " WHERE SKUERZEL = '" + srKuerzel + "'";

    try {

      resultSet = executeQuery(sql);
    } catch (SQLException ex) {

      throw new ApplicationException(ex.getMessage());
    }

    project.Studienrichtung targetStudienrichtung = null;
    try {

      if (resultSet.next()) {

        targetStudienrichtung = new project.Studienrichtung(srKuerzel, resultSet.getString("NAME"));
      } else {
        throw new ApplicationException("Studienrichtung nicht vorhanden!");
      }
    } catch (SQLException ex) {

      throw new ApplicationException(ex.getMessage());
    }

    project.Student studentToAnnounce =
        new project.Student(matrikel, name, vorname, adresse, targetStudienrichtung);

    /*
     * Zum Vergleich des Studenten, der eingetragen werden muss und dem
     * Studenten der in der Datenbank zu der übergebenen vorliegt
     */
    sql =
        "SELECT S.*, SR.NAME AS SRNAME"
            + " FROM STUDENT S, STUDIENRICHTUNG SR"
            + " WHERE MATRIKEL = '"
            + matrikel
            + "'"
            + " AND S.SKUERZEL = SR.SKUERZEL";

    try {

      resultSet = executeQuery(sql);
    } catch (SQLException ex) {

      throw new ApplicationException(ex.getMessage());
    }

    project.Studienrichtung sfdbStudienrichtung = null;
    project.Student studentFromDatabase = null;

    try {

      if (resultSet.next()) {
        sfdbStudienrichtung = new project.Studienrichtung(srKuerzel, resultSet.getString("SRNAME"));
        studentFromDatabase =
            new project.Student(
                resultSet.getString("MATRIKEL"),
                resultSet.getString("NAME"),
                resultSet.getString("VORNAME"),
                resultSet.getString("ADRESSE"),
                sfdbStudienrichtung);
      }
    } catch (SQLException ex) {

      throw new ApplicationException(ex.getMessage());
    }

    if (studentFromDatabase == null) {

      addStudent(
          studentToAnnounce.getMatrikel(),
          studentToAnnounce.getName(),
          studentToAnnounce.getVorname(),
          studentToAnnounce.getAdresse(),
          studentToAnnounce.getStudienrichtungKuerzel());

      sql =
          "INSERT INTO PRAKTIKUMSTEILNAHME"
              + " VALUES('"
              + studentToAnnounce.getMatrikel()
              + "',"
              + " '"
              + modul.getKuerzel()
              + "' ,"
              + " '"
              + semester
              + "',"
              + " 0)";
    } else {

      if (studentToAnnounce.equals(studentFromDatabase)) {

        sql =
            "INSERT INTO PRAKTIKUMSTEILNAHME"
                + " VALUES('"
                + studentToAnnounce.getMatrikel()
                + "',"
                + " '"
                + modul.getKuerzel()
                + "' ,"
                + " '"
                + semester
                + "',"
                + " 0)";
      } else {

        throw new ApplicationException("Student mit anderen Daten bereits im System vorhanden.");
      }
    }

    try {

      execute(sql);
    } catch (SQLException ex) {

      announced = false;
    }

    return announced;
  }