Hikaricp: Support asynchronous acquisition of a connection from the pool

Created on 18 Feb 2018  Â·  5Comments  Â·  Source: brettwooldridge/HikariCP

Currently, getConnection blocks current thread if a connection is not immediately available. It would be great to have an asynchronous version of this function that would accept a callback, or return a future. This callback/future would be completed when connection is available, thus unblocking a thread to do some other useful work, while waiting in a queue to access a database.

Such queue should be bound (have a limit on the number of items in the queue) and exception would be thrown if queue is full, thus allowing for controlled back-pressure propagation.

Most helpful comment

I was hoping to use it with Kotlin coroutines, and JSR won't be widely implemented, and thus generate demand, for at least several years…

All 5 comments

Oracle and the JSR community are currently working on the specification for a standard async JDBC API. When the specification becomes more solid, HikariCP will provide an implementation.

I was hoping to use it with Kotlin coroutines, and JSR won't be widely implemented, and thus generate demand, for at least several years…

This is a big problem for anyone using Vert.x and event loops since it can lead to deadlocks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kh-evgeniy picture kh-evgeniy  Â·  6Comments

coexia picture coexia  Â·  5Comments

sooyoung32 picture sooyoung32  Â·  5Comments

ssinganamalla picture ssinganamalla  Â·  6Comments

sumeetpri picture sumeetpri  Â·  3Comments