How to get database url from java.sql.Connection?

前端 未结 4 1311
无人共我
无人共我 2020-12-08 12:54

For given Connection instance how do I find out url that the Connection uses to connect the database ? Is it somewhere in Properties returned by Co

4条回答
  •  萌比男神i
    2020-12-08 13:27

    I believe you can use the DatabaseMetaData object from the Connection and then get the URL. Try:

    DatabaseMetaData dmd = connection.getMetaData();
    String url = dmd.getURL();
    

提交回复
热议问题