检测当前使用 Java 的数据库

发布于 2024-09-05 00:11:22 字数 90 浏览 2 评论 0原文

有没有办法检测当前使用Java连接的ODBC数据库? 例如,我想知道某个应用程序当前连接的是 Oracle 10g 还是 SQL Server 2005。 提前致谢。

Is there a way to detect the ODBC database currently being connected to with Java?
For example, I would like to know whether an application is currently connected to Oracle 10g or SQL Server 2005.
Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最终幸福 2024-09-12 00:11:22

如果您有java.sql.Connection类,getMetaData方法将返回数据库信息。从 DatabaseMetaData 对象中,您可以检索各种内容,例如驱动程序名称或连接 URL,以确定您的服务器类型。 edit 那里还有 getDatabaseProductName 方法。

If you have java.sql.Connection class, getMetaData method will return database information. From DatabaseMetaData object you can retrieve all kinds of stuff, like driver name or connection url, to determine your kind of server. edit There's also getDatabaseProductName method there.

早乙女 2024-09-12 00:11:22

为什么不从正在使用的驱动程序中提取它? IE如果你当前使用com.mysql.jdbc.Driver,那么你就知道你使用的是MySQL。

您正在将驱动程序类名称传递给某些东西,对吗?

Why not extract it from the driver that is in use? IE if your currently using com.mysql.jdbc.Driver, then you know that your using MySQL.

You are passing the driver class name to something, right?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文