I am developing a spring boot application that uses spring data jpa and connects to many different databases Eg will need to be Poster sql, mysql, ms-sql, mongodibi i need to create all datasets in runtime. The user has initially selected these data by GUI: - The driver (one from the list), -source, -port, -name, -password and finally he chose the local SQL database and writes to get the result. I read many things about it in stack and spring forums (for example, abstraRattingdatasource) but all these tutorials show how to create a data source with a static definition in XML configuration or Java Bean. Is it possible to make many datsources in runtime? How to manage transactions and how many sessions to create a factory? Is it possible to use @transnational annotation? What is the best way to do this? Can anyone tell me how can this "step by step"?
Hope this is not too long Reply;)
I have a Module has been developed which can be easily integrated into a spring project. This tenant-data source uses a meta-data source to keep the connection details. Absorrating datasource is used for tenant-data source.
Here you find my main implementation by using the extracting Detosor.
This is an example of how to integrate it. In this example I am using H2 embedded DB. But of course you can use whatever you want.
Feel free to modify it for your purposes, or ask questions when asked!
No comments:
Post a Comment