奇数 Oracle 连接 URL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14158263/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:21:36  来源:igfitidea点击:

Odd Oracle connection URL

javaoraclejdbc

提问by Aaron Digulla

One of our customers is trying to connect to an Oracle database with the following JDBC URL:

我们的一位客户正在尝试使用以下 JDBC URL 连接到 Oracle 数据库:

jdbc:oracle:thin:@(DESCRIPTION=(FAILOVER=ON)LOAD_BALANCE=OFF)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=server1.domain.com)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=server2.domain.com)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=FOO))) 

They get this error:

他们收到此错误:

Caused by: oracle.net.ns.NetException: NL Exception was generated
    at oracle.net.resolver.AddrResolution.resolveAddrTree(AddrResolution.java:614) ~[ojdbc5_11g-11.2.0.1.0.jar:11.2.0.1.0]
    at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:411) ~[ojdbc5_11g-11.2.0.1.0.jar:11.2.0.1.0]
    at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:672) ~[ojdbc5_11g-11.2.0.1.0.jar:11.2.0.1.0]
    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:237) ~[ojdbc5_11g-11.2.0.1.0.jar:11.2.0.1.0]
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042) ~[ojdbc5_11g-11.2.0.1.0.jar:11.2.0.1.0]
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301) ~[ojdbc5_11g-11.2.0.1.0.jar:11.2.0.1.0] 

Questions:

问题:

  1. I've never seen such a connection URL before. It looks more like an entry in TNSNAMES.ORA. How can I find out what this connection string means?

  2. What could be causing this useless error message?

  1. 我以前从未见过这样的连接 URL。它看起来更像是 TNSNAMES.ORA 中的一个条目。如何找出此连接字符串的含义?

  2. 什么可能导致此无用的错误消息?

回答by Mark Rotteveel

The syntax is the 'Oracle Net connection descriptor syntax', see table 8.3 in the JDBC Developers Guide.

语法是“Oracle Net 连接描述符语法”,请参阅JDBC 开发人员指南中的表 8.3 。

The syntax is indeed the same as the syntax used in tnsnames.ora; this syntax is described in the Oracle Database Net Services Reference.

语法确实与tnsnames.ora; 中使用的语法相同。此语法在Oracle Database Net Services Reference 中有所描述。

As to the specific issue, it looks to me like you have unbalanced parentheses in the descriptor, specifically:

至于具体问题,在我看来,您在描述符中有不平衡的括号,特别是:

(FAILOVER=ON)LOAD_BALANCE=OFF)

Should be:

应该:

(FAILOVER=ON)(LOAD_BALANCE=OFF)

(note the additional (.)

(注意额外的(.)

回答by shyam mohan

I generated the following connection URL from your tnsnames entry :

我从您的 tnsnames 条目生成了以下连接 URL:

jdbc:oracle:thin:@server1.domain.com:1521/FOO

try to use the above connection URL. Also do check if the listener is up and running : in windows : ctrl + r, services.msc, check whether service : "Oracle*TNSListener" is started.

尝试使用上面的连接 URL。同样做检查,如果听者启动并运行:在Windows中:ctrl + rservices.msc,检查服务是否:“甲骨文*的TNSListener”启动。

jdbc:oracle:thin:@(DESCRIPTION=(FAILOVER=ON)LOAD_BALANCE=OFF)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=server1.domain.com)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=server2.domain.com)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=FOO)))