Dynamic databases in play framework

51 Views Asked by At

In the play documentation we can find how configure a database connection in the application.conf file such as

default.driver=org.postgresql.Driver
default.url="jdbc:postgresql://urlConnection"
default.user=yourUser
default.password="yourPassword"

ebean.default = ["models.*"]

but I need to create different connections depending on the configuration of each account (each account has in its configuration the information for the connection to the database)

So in the default database I have the accounts and their configuration and, on the other hand, in other databases I have the rest of data.

How could I create the rest of the connections to the databases and make them work in the same way as the default database? Being dynamic, I cannot include them in the application.conf

The idea would be to create the databases as database + accountId and have them cached or somehow to not have to connect again if there is already a connection with that name

0

There are 0 best solutions below