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.
1 Answer
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.
1 Comment
user1015388
sure, let me try that