Skip to content

Connection callbacks

Zsolt Herpai edited this page Feb 5, 2015 · 1 revision

A ConnectionProvider can be implemented to fetch Connection objects from Connection callbacks. Such mechanism is relatively often used in frameworks to provide access to managed Connections. The following example uses Spring's JdbcTemplate as an example:

JdbcTemplate jdbcTemplate = ...
ConnectionProvider provider = query -> {
    jdbcTemplate.execute(connection -> {
        query.receive(connection);
    });
}

Clone this wiki locally