如何从java.sql.Connection获取数据库URL? [英] How to get database url from java.sql.Connection?

查看:885
本文介绍了如何从java.sql.Connection获取数据库URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于给定的 连接 实例如何找到连接用于连接数据库的URL?是属性中的某处#getClientInfo%28%29rel =noreferrer> 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

推荐答案

连接 具有 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆