Spring Data Reactive Relational Database Connectivity or R2DBC allows developers to work with SQL databases in a fully-reactive and asynchronous manner, thus moving away from the "one-thread-execution" servlet container model. With the SQL drivers based on the new R2DBC specification from respective vendors, the drivers thus provide a completely new set of APIs to communicate effectively with Relational databases in a non-blocking manner. More details can be found here and here.
This github repository is to document a working code with the minimum required maven dependencies to get a successful 200 GET HTTP Response code. Lest assured, the code is supposed to work with the below mentioned steps.
This code base is based on Spring Data R2DBC with Oracle relational database.
- Connect to Oracle in asynchronous mode from Spring boot
- Validate request and throw custom validation exception
- Handle any exceptions and throws meaningful error messages
- Maintain test classes execution coverage of 85 percentile and above
- Login into container-registry.oracle.com using your oracle credentials. Choose database >> standard. Accept the _ Licence agreement_. You will now get a docker pull command for the Oracle database image. Refer here for more details
- Run
docker login container-registry.oracle.com
- Run
docker run -d --name oracle21c -p 1521:1521 container-registry.oracle.com/database/enterprise:21.3.0.0
- Run
docker exec oracle21c ./setPassword.sh <your-new-oracle-password-for-sys-user>
- Connect to database using Oracle SQL Developer
username : SYSTEM
password : "your-new-oracle-password-for-sys-user"
hostname : localhost
port : 1521
SID : ORCLCDB - Create customer table.
CREATE TABLE CUSTOMERS ( CUST_ID NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY, NAME VARCHAR2(255) NOT NULL , ADDRESS VARCHAR2(255) NOT NULL , COUNTRY VARCHAR2(255) NOT NULL , CREATED_AT TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
- Run unit tests & build project :
mvn clean package -T 8
- Import spring-reactive-urls.json in Postman.
- Hit the APIs.