There are a couple of independent drivers such as Reactiverse's reactive-pg-client. These drivers come with a vendor-specific API and aren't really suited for broader adoption. Client integrators would need to provide additional layers to expose a common API. New drivers cannot easily be plugged into the client library. In contrast, having a standard API would allow pluggability while decoupling clients from database specific solutions – a huge value for all.
Oracle announced ADBA, which is an initiative to provide a standardized API for asynchronous database access in Java by using futures. Everything in ADBA is a work in progress, and the team behind ADBA is happy to get feedback. A bunch of Postgres folks is working on a Postgres ADBA driver that can be used for first experiments. PgNio is another asynchronous driver for Postgres that started experimenting with ADBA.
xxxxxxxxxx
DataSource ds = dataSource();
CompletableFuture<Long> t;
try (Session session = ds.getSession()) {
Submission<Long> submit = session
.<Long>rowCountOperation(
"INSERT INTO legoset (id, name, manual) " +
"VALUES($1, $2, $3)")
.set("$1", 42055, AdbaType.INTEGER)
.set("$2", "Description", AdbaType.VARCHAR)
.set("$3", null, AdbaType.INTEGER)
.apply(Result.RowCount::getCount)
.submit();
t = submit.getCompletionStage().toCompletableFuture();
}
t.join();
CompletableFuture<List<Map<String, Object>>> t;
try (Session session = ds.getSession()) {
Submission<List<Map<String, Object>>> submit = session
.<List<Map<String, Object>>> rowOperation(
"SELECT id, name, manual FROM legoset")
.collect(collectToMap()) // custom collector
.submit();
t = submit.getCompletionStage().toCompletableFuture();
}
t.join();
https://spring.io/blog/2018/12/07/reactive-programming-and-relational-databases