oracle 如何从sql查询中获取oracle端口号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1496573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to get oracle port no from sql query
提问by Fell
Is it possible to get the oracle server port no from a sql query?
是否可以从 sql 查询中获取 oracle 服务器端口号?
Thanks,
Fell
谢谢,
落
回答by davek
回答by Nick Holt
No, but in order to run a query you're going to need a connection to the DB so I suspect you can get the port using a call to java.sql.DatabaseMetaData.getURL()
. Not sure exactly what the Oracle drivers return but something like this should do the trick:
不,但是为了运行查询,您将需要连接到数据库,所以我怀疑您可以通过调用java.sql.DatabaseMetaData.getURL()
. 不确定 Oracle 驱动程序返回的究竟是什么,但这样的事情应该可以解决问题:
String url = connection.getMetadata().getURL();
String port = url.substring(url.indexOf(":"), url.indexof("/", url.indexOf(":")) - 1);