0

I have a Spring boot application with Oracle as back end. I use Spring datasource to connect to database. But now we have a requirement to connect to 2 DB environments.

In REST endpoint we have a query param called env. (?env=Demo). If the env is Demo connect to Demo DB if it is empty then connect to prod DB. I was able to achieve this by having two datasources in applicaiton.properties. The problem with this approach is I have to add if condition(to check the env) in all my API's.

It there a way by which I can dynamically choose data source based on query string. i.e. with minimal code change. I do not want to deploy two instance(1 for demo and 1 for prod)

Thiagarajan Ramanathan
  • 1,035
  • 5
  • 24
  • 32

0 Answers0