Using JdbcClient to access the database
In the previous recipe, we used JdbcTemplate to access the database. The JdbcClient is an enhanced JDBC client that provides a Fluent interaction mode. JdbcClient has been introduced in Spring Framework 6.1, and it’s available since Spring Boot 3.2.
In this recipe, we’ll learn how to use JdbcClient by performing some simple queries to the database.
Getting ready
In this recipe, we’ll need a PostgreSQL database. You can reuse the same database created in the previous recipe, Connecting your application to PostgreSQL. You can reuse the project from the same recipe as well, as the dependencies are the same. I prepared a working version that you can use as a starting point for this recipe. You can find it in the book’s GitHub repository at https://github.com/PacktPublishing/Spring-Boot-3.0-Cookbook, in chapter5/recipe5-2/start
folder.
How to do it...
Let’s prepare some queries using JdbcClient instead...