Using Spring to connect to a dynamically changing database

I saw a lot of solutions, because of which you first configure various data sources statically through XML, and then use AbstractRoutingDataSource to return the key that you use when defining the data source.

Like here: dynamic data routing

But my business is different. I do not know how many databases could be in my web application. I am creating an application in which each user downloads a small h2 db dump from a desktop application. The web application will download the h2 db dump and then connect to it.

So that everything was easy to understand. Each user will have their own database file, which I need to connect as soon as the user logs in. Since the number of users is not fixed, I don’t know how many databases I need to connect, so I can’t statically configure them in the XML file.

How to do it in Spring? Also not sure if this helps, these h2 dbs are read-only. I will not write to them.

This is my configuration.

Maven, Spring MVC, JOOQ, H2 DB

+3
source share
1 answer

If you want to dynamically change database changes, you need to write a UI for information about the database source and install spring in version 4.0 configuration files.

0
source

All Articles