Skip to content

Multiple DataSource configuration #234

@mcherb

Description

@mcherb

I have multiple datasources, each points to a different schema in the same database.

dsx.datasource.jdbc-url=jdbc:postgresql://localhost:5432/db?currentSchema=x
dsx.datasource.hikari.data-source-properties.currentSchema=x
dsy.datasource.jdbc-url=jdbc:postgresql://localhost:5432/db?currentSchema=y
dsy.datasource.hikari.data-source-properties.currentSchema=y
dsz.datasource.jdbc-url=jdbc:postgresql://localhost:5432/db?currentSchema=z
dsz.datasource.hikari.data-source-properties.currentSchema=z

I'm using the AutoConfigureEmbeddedDatabase annotation like so:

@AutoConfigureEmbeddedDatabase(provider = ZONKY, beanName = "xDataSource")
@AutoConfigureEmbeddedDatabase(provider = ZONKY, beanName = "yDataSource")
@AutoConfigureEmbeddedDatabase(provider = ZONKY, beanName = "zDataSource")

So far, so good

Beside, I have a sql query which is joining multiple schema together; something like :

select * from x.table x join y.table y on ...

EmbeddedDatabase will replace the original datasources whithout taking the original configuration (like the schema name).

From the documentation I've found that I can set currentSchema with some additional configuration :

zonky.test.database.postgres.client.properties.currentSchema=x

But his configuration will affect all the replaced dataSources. I'm I right ?

Is there a way to use the same configuration with the datasource bean name, for instance:

zonky.test.database.postgres.client.xDataSource.properties.currentSchema=x

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions