class MysqlEventRepo {

    public List<MysqlEvent> getNewEventsForListener(Listener listener, Connection connection)
            throws DataAccessException {
        verifyListenerExists(listener, connection);
        try (
                PreparedStatement stmt = connection.prepareStatement(GET_EVENTS_FOR_LISTENER_QUERY)
        ) {
            Date lastCheckDate = listener.getLastCheck();
            listenerRepo.refreshLastCheck(listener, connection);

            stmt.setObject(1, listener.getLastEventId());
            stmt.setObject(2, lastCheckDate);
            stmt.setObject(3, listener.getId());
            ResultSet rs = stmt.executeQuery();

            List<MysqlEvent> result = Lists.newArrayList();
            long maxEventId = 0l;
            while (rs.next()) {
                maxEventId = Math.max(rs.getLong(EVENT_ID_COL), maxEventId);
                result.add(extractEvent(rs));
            }

            if (maxEventId > listener.getLastEventId()) {
                listener.setLastEventId(maxEventId);
                listenerRepo.update(listener, connection);
            }

            return result;
        } catch (SQLException e) {
            throw new DataAccessException("Could not get new events for listener with id:" + listener.getId(), e);
        }
    }

      MysqlEventRepo();

}