A
A
Atlllantis2017-12-02 21:53:29
MySQL
Atlllantis, 2017-12-02 21:53:29

Is there a ready-made solution for asynchronous work with the database?

Hello.
Is there any ready-made solution for working with the database ( I use the mariadb driver ) in asynchronous mode with a pool of threads?
Didn't find anything on google.
Now for each active connection I create a separate thread in which I actually work with the database.
But it is difficult to control everything, the slightest mistake and everything can collapse - a ready-made and tested solution would come in handy. In addition, my implementation is clearly not the best (and not correct).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2017-12-02
@sergey-gornostaev

There are a whole bunch of wrappers for jdbc drivers on github that emulate asynchrony using a thread pool. But I haven't seen anything really good and universally recognized either. There is hope for the asynchronous JDBC promised in Java 10, but so far the most harmonious way to work with the database asynchronously is to wrap requests in a CompletableFuture.

D
Denis Zagaevsky, 2017-12-03
@zagayevskiy

RxJava has already been advised, you can use it. Wrap connections in Observable and off we go. I advise you to look in her direction, at least.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question