I am wondering how can I get the database instance name from DatabaseMetaData, or is there any way I can do that, kind of stuck here, thanks for any pointers!
How to get sqlserver database name from datasource name in Java
Even
I am wondering how can I get the database instance name from DatabaseMetaData, or is there any way I can do that, kind of stuck here, thanks for any pointers!
How to get sqlserver database name from datasource name in Java
Even
Once you've obtained a database connection:
// url is usually in the format jdbc:mysql://<ip address>:<port>/<database name>
String url = theConnection..getMetaData().getURL();
String databaseName = StringUtils.substringAfterLast(url, "/");
The above code uses StringUtils in Apache Commons Lang 3