Retrieve Database name from dataSource

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Retrieve Database name from dataSource

latusaki
This post was updated on .
Inside my config.groovy file I define dataSource.url='jdbc:mysql://localhost/mydbname?autoReconnect=true&characterEncoding=utf8'

Is it possible to retrieve 'mydbname' from within a controller? I have injected dataSource, which is giving a
org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy but from there, I cant figure how to get the DB name. The DB name should be retrieved without any String parsing, as the configurations used for the app can change a lot between environments, so ideally I am looking for a method like .getDatasourceName()

I have tried this:
`flash.message = "DB name ${dataSource.getConnection().getClientInfo()}"` but the message returned is this: `DB name [:]`