如何从 java.sql.Connection 获取数据库 url? [英] How to get database url from java.sql.Connection?
本文介绍了如何从 java.sql.Connection 获取数据库 url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于给定的Connection
实例如何找出 Connection
用于连接数据库的 url?它是否在 Connection.getClientInfo()
方法?
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 Connection.getClientInfo()
method?
如果您需要我提供更清晰的描述,欢迎所有评论.谢谢
If there you need me to provide clearer description all comments are welcome. Thank you
推荐答案
Connection
有 getMetaData()
返回 DatabaseMetaData
.DatabaseMetaData
有getURL()
返回此 DBMS 的 URL.
Connection
has the getMetaData()
to return DatabaseMetaData
. DatabaseMetaData
has the getURL()
to return the URL for this DBMS.
这篇关于如何从 java.sql.Connection 获取数据库 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文