Search code examples
javaspringloggingjdbcdatasource

JdbcTemplate — logging the dataSource connection url


is there a way to log the JdbcTemplate's DataSource connection URL in Java?

The field exists in the DataSource, but there ain't a getter to access it. Of course I could read the DataSource properties from the application context xml, but I'd like to do it the other way.


Solution

  • If the field exists, would you consider using reflection to access it? The approach may not be future-proof but may be sufficient for your needs.