Unleashing the Power of Vector Data Types with Oracle R2DBC: Accelerating Generative AI Solutions with Reactive Streams and the Oracle Database 23ai

Introduction
R2DBC stands for Reactive Relational Database Connectivity, an open specification for asynchronous, non-blocking communication with relational databases. It adopts a reactive programming model for interacting with databases, allowing developers to work with streams of data rather than traditional blocking calls, aligning with the Reactive Streams specification.
If you need an introduction to R2DBC, please check my previous blog post — Getting Started with Reactive Relational Database Connectivity and the Oracle R2DBC Driver
This blog post focuses on exploring vector data type support in the Oracle R2DBC driver, as it opens the door to creating Generative AI applications that can combine vector-based similarity searches as well as reactive streams. Please note that the 1.3.0 release of Oracle R2DBC implements version 1.0.0.RELEASE of the R2DBC SPI.
New features in this release (1.3.0):
Updated dependencies:
- Updated Oracle JDBC driver from 21.11.0.0 to 23.6.0.24.10+
- Updated Project Reactor Core from 3.5.11 to 3.6.11
So, without further ado, let’s get started!
Prerequisites
- JDK — Java Development Kit 17 or newer
- Oracle Database Free Release 23ai — Container Image
- Oracle JDBC Driver 23ai (23.4.0.24.05) — Maven Central
- Your preferred Java IDE — Eclipse, IntelliJ, VS Code
- Apache Maven
Hot to use the Vector data type with Oracle R2DBC 1.3.0
Here’s a practical, hands-on guide to integrating Oracle R2DBC 1.3.0 with VECTOR
data type support into your Java applications. We’ll assume you’re familiar with Java, Maven, and reactive programming concepts (Project Reactor, RxJava, Vert.x, Akka, etc.).
Once again, if you need an introduction to R2DBC, please check my previous blog post — Getting Started with Reactive Relational Database Connectivity and the Oracle R2DBC Driver
Step 1: Set Up Your Maven Project
To use Oracle R2DBC 1.3.0, you’ll need to configure your Maven (pom.xml) file with the appropriate dependencies.
<dependencies>
<dependency>
<groupId>com.oracle.database.r2dbc</groupId>
<artifactId>oracle-r2dbc</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.7.3</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc17</artifactId>
<version>23.7.0.25.01</version>
</dependency>
</dependencies>
Step 2: Configure Your Oracle Database Connection
Ensure you have an Oracle Database 23ai instance (check the section below), as it supports VECTOR
data types. As usual, update your configuration properties file (src/main/resources/config.properties) with the JDBC connection details.
HOST=<HOSTNAME>
PORT=<ORACLE_DB_PORT>
DATABASE=<ORACLE_DATABASE_NAME>
USER=<ORACLE_DATABASE_USER>
PASSWORD=<ORACLE_DABASE_PASSWORD>
DRIVER=oracle
DB_TABLE_NAME=<DB_TABLE_NAME>
Step 3: Create a Table with a Vector Column
VECTOR
data type with a database column that allows you to store multidimensional arrays directly in the database. Execute the following SQL DDL statement to create a table.
CREATE TABLE vector_data (ID NUMBER PRIMARY KEY, embedding VECTOR(3, FLOAT32));
COMMIT;
--DESCRIBE vector_data;
--SELECT * FROM vector_data;
Step 4: Write Code with Oracle R2DBC to Insert and Query Vectors
Here’s our sample class on using Oracle R2DBC to insert and retrieve vector data. The code is relatively straightforward if you’re familiar with reactive programming and Project Reactor.
Please note that the Java method VECTOR
.ofFloat32Values(java.lang.Object object) is required to obtain the proper vector data representation.
Step 5: Add the database configuration class
Add this class as it will be needed to configure the database connection.
Step 6: Test the sample app
Run your application from the CLI or your preferred IDE (IntelliJ, VS Code, Eclipse, others) and verify that the vector data is stored and retrieved correctly, as shown below.
From the console

From the database

Oracle Database 23ai
If you want to test everything, start a database with a lightweight Docker container. The summarized steps are provided below. First, run the docker pull command below (for Windows):
docker pull container-registry.oracle.com/database/free:latest
Now, you can run the docker images command below to confirm that it was pulled properly:

Oracle Database 23ai — container image
Then, run the command below from the Windows Command Prompt (cmd):
docker run -d -p 1521:1521 -e ORACLE_PWD=<your_password> -v oracle-volume:/opt/oracle/oradata container-registry.oracle.com/database/free:latest
Replace <your password> above with your chosen password as required. The command above will run a new persistent database container (data is kept throughout container lifecycles).
If everything goes well, you can run the command docker ps -al to confirm that your container instance is starting as expected.

Please note that the Oracle Database 23ai will be ready to use when the STATUS field shows (healthy), as below.

There are some additional options if you want to configure environment variables to support your connection details, such as username, password, and other variables. You can also check more details about the specific database user (SYS, SYSTEM, PDBADMIN) you may want to use.
Wrapping it up
You learned about the Oracle R2DBC Driver, released as an Open-source component on GitHub. We explored using the VECTOR
data type support in the Oracle R2DBC driver, as it opens the door to creating Generative AI applications that can combine vector-based similarity searches with many Reactive Streams frameworks in Java!
As one last tip, I invite you to check out the new Database Navigator tool published at JetBrains Marketplace. In a nutshell, it features a robust SQL and PL/SQL editor with advanced capabilities for managing database connections, executing scripts, editing database objects, and modifying data and code with IntelliJ!
I will soon post more examples of scenarios involving LangChain4J, the OracleEmbeddingStore, GraalVM, Micronaut, Quarkus, and other GenAI / Agentic AI-related topics!
That’s it! I hope you liked this blog post, so stay tuned!
References
Oracle R2DBC Driver
Oracle AI Vector Search Technical Architecture
Oracle Database Free Release 23ai — Container Image
Oracle® Database JDBC Java API Reference, Release 23ai
Database Navigator — JetBrains Marketplace
Developers Guide For Oracle JDBC on Maven Central
Develop Java applications with Oracle Database
Oracle Developers and Oracle OCI Free Tier
Join our Oracle Developers channel on Slack to discuss Java, GenAI, Agentic AI, JDK, JDBC, GraalVM, Micronaut, Spring Boot, Helidon, Quarkus, Reactive Streams, Cloud, DevOps, SRE, IaC, and other topics!
Build, test, and deploy your applications on Oracle Cloud — for free! Get access to OCI Cloud Free Tier!