Ramandeep
Ramandeep

Reputation: 45

can multiple database connection be build using jdbi

My requirement is too fetch data by joining tables from multiple databases.

Is their any way to setup connection with multiple databases using jbdi

Upvotes: 3

Views: 1258

Answers (2)

shravan
shravan

Reputation: 1

I'm trying to inject two DBIs for two mysql data sources but I keep getting the below error:

A binding to org.skife.jdbi.v2.DBI was already configured at com.mmt.clm.ClmModule.provideDBI(). at com.mmt.clm.ClmModule.provideMmtDBI

Is there any way to inject multiple DBIs for multiple data sources

Upvotes: 0

qualidafial
qualidafial

Reputation: 6822

Each DBI instance is tied to a single java.sql.DataSource, which I've only seen connect to a single database. So the answer to your question is, probably not.

You can however construct a DBI per database, query them separately, and join the result on your application server.

Depending on your use case (I'm assuming reporting?), it might be more appropriate to look into a data warehouse solution, and set up an ETL (extract, transform, and load) for each of your separate database to feed into the warehouse. Then you can produce reports from the warehouse without impacting performance of the other systems.

Upvotes: 2

Related Questions