@Override
    public Match findMatchById(Long id) {
        checkDataSource();
        if (id == null) {
            throw new IllegalArgumentException("id is null");
        }
        try (Connection conn = dataSource.getConnection();
                PreparedStatement st = conn.prepareStatement("SELECT id, hometeamid, awayteamid, date, homeowngoals, awayowngoals"
                        + ", homeadvantagegoals, awayadvantagegoals, homecontumationgoals, awaycontumationgoals, hometechnicalgoals, awaytechnicalgoals, matchresult"
                        + " FROM MATCHES WHERE id = ?")) {
            st.setLong(1, id);

            ResultSet rs = st.executeQuery();

            if (rs.next()) {
                Match match = resultSetToMatch(rs);

                if (rs.next()) {
                    throw new ServiceFailureException("Internal error: More entities with the same id found "
                            + "(source id: " + id + ", found " + match + " and " + resultSetToMatch(rs));
                }
                return match;
            } else {
                return null;
            }

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