Connecting to PostgreSQL using Spring Data R2DBC
Using a Reactive database driver makes sense as we need to connect our Reactive application to PostgreSQL. This means the application is not blocked when it makes requests to the database. There is a Java specification to integrate SQL databases using reactive drivers named R2DBC. Spring Framework supports R2DBC with Spring Data R2DBC, which is part of the larger Spring Data family.
Spring Data R2DBC applies familiar Spring abstractions for R2DBC. You may use R2dbcEntityTemplate
, running statements using the Criteria API and Reactive Repositories, among other features.
In this recipe, we’ll learn how to connect to PostgreSQL using Reactive Repositories and some of the differences between Reactive and non-reactive Repositories. We’ll also learn how to configure Flyway for database migrations.
Getting ready
For this recipe, we’ll need a PostgreSQL database. You can use the instructions from the Getting...