简体   繁体   中英

Using a JNDI datasource can I get the connection string from it?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM