简体   繁体   中英

Connect to multiple database schemas in Spring boot application

In my spring boot application I am using Oracle as the database. The database has different schemas. I have a requirement, to list all the schemas and connect to the database using that schema in a loop and do some query on the tables. I have seen some blogs to connect to different schemas by defining datasource in application.properties. I don't want to do that becuase I have around 40+ schemas defined and I don't want to define those many datasources.

I think it's a better solution to connect with one account (with read permission to all the schema's) to the database and use a simple SQL query to fetch all the schema's.

If you know the schema's you can build custom SQL queries to fetch the data from each schema. (select * from SCHEMA1.sometable)

I think it's not a good idea to create connection for each schema in your situation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM