layout |
---|
default |
The Reactive Relational Database Connectivity (R2DBC) project brings reactive programming APIs to relational databases.
Based on the Reactive Streams specification. R2DBC is founded on the Reactive Streams specification, which provides a fully-reactive non-blocking API.
Works with relational databases. In contrast to the blocking nature of JDBC, R2DBC allows you to work with SQL databases using a reactive API.
Supports scalable solutions. With Reactive Streams, R2DBC enables you to move from the classic "one thread per connection" model to a more powerful and scalable approach.
Provides an open specification. R2DBC is an open specification and establishes a Service Provider Interface (SPI) for driver vendors to implement and clients to consume.
Example Query
ConnectionFactory connectionFactory = ConnectionFactories .get("r2dbc:h2:mem:///testdb");
Mono.from(connectionFactory.create()) .flatMapMany(connection -> connection .createStatement("SELECT firstname FROM PERSON WHERE age > $1") .bind("$1", 42) .execute()) .flatMap(result -> result .map((row, rowMetadata) -> row.get("firstname", String.class))) .doOnNext(System.out::println) .subscribe();
ConnectionFactory connectionFactory = ConnectionFactories .get("r2dbc:h2:mem:///testdb");
Single.fromPublisher(connectionFactory.create()).toFlowable() .flatMap(connection -> connection .createStatement("SELECT firstname FROM PERSON WHERE age > $1") .bind("$1", 42) .execute()) .flatMap(result -> result .map((row, rowMetadata) -> row.get("firstname", String.class))) .doOnNext(System.out::println) .subscribe();
ConnectionFactory connectionFactory = ConnectionFactories .get("r2dbc:h2:mem:///testdb");
Uni.createFrom().publisher(connectionFactory.create()) .onItem().transformToMulti(connection -> connection .createStatement("SELECT firstname FROM PERSON WHERE age > $1") .bind("$1", 42) .execute()) .onItem().transform(result -> result .map((row, rowMetadata) -> row.get("firstname", String.class))) .subscribe().with(System.out::println);
- Broad type conversion
- Transactions, isolation levels, and save points
- Batching
- BLOB/CLOB support
- Connection URLs (
r2dbc:<driver>://<host>:<port>/<database>
) ConnectionFactory
discovery and configuration based on Java'sServiceLoader
- Typed Exceptions
- Extensible Interface
- Observability
- TCK
Existing standards, based on blocking I/O, cut off reactive programming from relational database users. R2DBC specifies a new API to allow reactive code that works efficiently with relational databases.
R2DBC is a specification designed from the ground up for reactive programming with SQL databases. It defines a non-blocking SPI for database driver implementors and client library authors. R2DBC drivers fully implement the database wire protocol on top of a non-blocking I/O layer.
R2DBC aims for a minimal SPI surface, specifying only parts that differ across databases, and is fully reactive and backpressure-aware all the way down to the database. It is intended primarily as a driver SPI to be consumed by client libraries and not intended to be used directly in application code.
R2DBC supports cloud-native applications using relational databases such as PostgreSQL, MySQL, and others. Application developers are free to pick the right database for the job without being confined by APIs.
Join the R2DBC Community Forum to learn more about R2DBC, get your R2DBC questions answered, and interact with other R2DBC developers.
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> <script> function hideOtherTabs(tabList, tab, tabPrefix){ for (index = 0; index < tabList.length; index++) { if(tabPrefix+tab!=tabPrefix+tabList[index]){ $('div#'+tabPrefix+tabList[index]).hide(); } } } $(document).ready( function(){ var tabPrefix = 'home_'; var tabs = ['tab1', 'tab2', 'tab3']; for (index = 1; index < tabs.length; index++) { jQuery('div#'+tabPrefix+tabs[index]).hide(); } $('ul.tab_links li').click( function(){ var tabID = $(this).attr('id'); //show this tab $('div#'+tabPrefix+tabID).show(); //hide others hideOtherTabs(tabs,tabID,tabPrefix); }); }); </script>