/**
   * ploeg toevoegen aan database
   *
   * @param p de ploeg die je wilt toevoegen
   * @throws DBException
   */
  public void toevoegenPloeg(Ploeg p) throws DBException {

    // connectie tot stand brengen (en automatisch sluiten)
    try (Connection conn = ConnectionManager.getConnection(); ) {
      // preparedStatement opstellen (en automtisch sluiten)
      if (p.getTrainer() != null) {

        try (PreparedStatement stmt =
            conn.prepareStatement(
                "INSERT INTO ploeg (`naam`, `niveau`, `trainer_id`) VALUES (?,?,?)"); ) {
          stmt.setString(1, p.getNaam());
          stmt.setString(2, p.getCategorie().getTekst());
          stmt.setInt(3, p.getTrainer());

          stmt.execute();
        } catch (SQLException sqlEx) {
          throw new DBException("SQL-exception in toevoegenPloeg(PloegBag p) - statement" + sqlEx);
        }
      } else {
        try (PreparedStatement stmt =
            conn.prepareStatement("INSERT INTO ploeg (`naam`, `niveau`) VALUES (?,?)"); ) {
          stmt.setString(1, p.getNaam());
          stmt.setString(2, p.getCategorie().getTekst());

          stmt.execute();
        } catch (SQLException sqlEx) {
          throw new DBException("SQL-exception in toevoegenPloeg(PloegBag p) - statement" + sqlEx);
        }
      }

    } catch (SQLException sqlEx) {
      throw new DBException("SQL-exception in toevoegenPloeg(PloegBag p) - connection" + sqlEx);
    }
  }