Drivers
Service Provider Interface (SPI)
R2DBC defines an SPI all data store drivers must implement.
- r2dbc-spi: a set of interfaces defining the SPI for R2DBC.
- r2dbc-spi-test: within the SPI repository, a Technology Compatibility Kit (TCK) for verifying a driver’s implementation.
One noticeable difference between R2DBC and JDBC is that JDBC is aimed at both driver writers and application developers. Driver developers and application developers operate at different levels, making this one-size-fits-all model less than ideal.
R2DBC’s SPI is deliberately designed to be as small as possible, while still including features critical for any relational data store. This means that the SPI does not target extensions which are specific to a data store.
To ease implementation, R2DBC also provides a test interface (a veritable TCK) to ensure your driver is fully operational.
Driver Implementations
R2DBC drivers implement the SPI listed above. The ones currently supported include:
- clickhouse-r2dbc - R2DBC wrapper of async Java client for ClickHouse.
- cloud-spanner-r2dbc - driver for Google Cloud Spanner.
- jasync-sql - R2DBC wrapper for Java & Kotlin Async Database Driver for MySQL and PostgreSQL (written in Kotlin).
- oracle-r2dbc - native driver implemented for Oracle.
- r2dbc-h2 - native driver implemented for H2 as a test database.
- r2dbc-mariadb - native driver implemented for MariaDB.
- r2dbc-mssql - native driver implemented for Microsoft SQL Server.
- r2dbc-mysql - native driver implemented for MySQL (previously mirromutth/r2dbc-mysql).
- r2dbc-postgresql - native driver implemented for PostgreSQL.
Connection Pooling
The following connection pool implementations are available for R2DBC:
- r2dbc-pool - reactive connection pooling using Reactor Pool.
Observability
Observability is provided through r2dbc-proxy
.
Implementing a Driver
R2DBC has a clearly-defined SPI, which you must implement to host a solution for your data store. To build an implementation, add the following artifact to your build:
- Group
io.r2dbc
- Artifact
r2dbc-spi
The key interface that all driver providers must implement is the Connection
, along with a set of other interfaces.
Check out the specification for details on R2DBC Driver Compliance.
There are other parts to implement, but this is the core.
Technology Compatibility Kit (TCK)
R2DBC also has a suite of test cases to verify your driver’s support. Your data store implementation should import a test-scoped dependency on the following artifact:
- Group
io.r2dbc
- Artifact
r2dbc-spi-test
To run all of the expected tests, write an implementation of the TCK’s TestKit
test.