Reputation: 491
I have my application on Tomcat with a JNDI datasource. I need to access the connection string from it. Is there a way to do that in my application?
Upvotes: 3
Views: 2163
Reputation: 7371
You can try the following:
DataSource ds ...
Connection conn = ds.getConnection();
DatabaseMetadata dbmd = conn.getMetaData();
System.out.println(dbmd.getURL());
You can get more info of DataBaseMetadata chedk this:
http://docs.oracle.com/javase/6/docs/api/java/sql/DatabaseMetaData.html
Upvotes: 5