I am connecting to multiple databases in my spring-boot app using Spring Data JPA by determining which database to connect at runtime. How can I check for validation on which database am I actually connected to on which my queries are running?
Try to get the URL from the Datasource, maybe will do it:
dataSource.getConnection().getMetaData().getURL();
Checkout DatabaseMetaData
documentation for complete details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With