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.
Currently supported databases are PostGres, MSSQL, MySQL, MariaDB, Oracle and H2.
pom.xml for H2:
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-h2</artifactId>
</dependency>
</dependencies>ORM with Spring Data R2DBC
Spring Data R2DBC enables us to write non-blocking code for interacting with databases. Unlike the other Spring Data projects, Spring Data R2DBC isn’t an ORM and has some limitations. One of those limitations is mapping joins for entities.
R2DBC-PostgreSQL-example: https://jreact.com/index.php/2023/11/07/reactive-programming-with-postgresql-in-java/
