public static <R> R contextResult(final DataSource dataSource,
                                      final Function<DSLContext, R> function) {
        R result;
        try (final Connection connection = dataSource.getConnection()) {
            try {
                checkDataSource(dataSource);
                final DSLContext context = createContext(connection);
                result = function.apply(context);
            } finally {
                releaseDataSource();
            }
        } catch (final Exception e) {
            throw convertException(e);
        }
        return result;
    }
If {@code isTimed} is {@code true} it will measure the duration of consumer,
else it will return a zero duration. {@code isTimed} can be set using
{@code LOGGER.isDebugEnabled()} for example.
stroom-db-util/src/main/java/stroom/db/util/JooqUtil.java