@Override
    public void createTeam(Team team) {
        checkDataSource();
        validate(team);

        if (team.getId() != null) {
            throw new IllegalArgumentException("Team aleready exists" + team.toString());
        }
        try (Connection conn = dataSource.getConnection();
                PreparedStatement st = conn.prepareStatement("INSERT INTO TEAMS (name, coach, status) VALUES (?,?,?)", Statement.RETURN_GENERATED_KEYS)) {
            st.setString(1, team.getName());
            st.setString(2, team.getCoach());
            st.setString(3, team.getStatus().toString());

            int addedRows = st.executeUpdate();

            if (addedRows != 1) {
                throw new ServiceFailureException("Internal Error: More rows inserted when trying to insert team " + team.toString());
            }

            ResultSet key = st.getGeneratedKeys();
            Long id = key.getLong(1);

            if (key.next()) {
                throw new IllegalArgumentException("Given ResultSet contains more rows");
            }
            team.setId(id);

        } catch (SQLException ex) {
            String msg = "error when inserting team" + team.toString();
            Logger.getLogger(TeamMngrImpl.class.getName()).log(Level.SEVERE, msg, ex);
            throw new ServiceFailureException(msg);
        }
    }