JDBC:Oracle 应用服务器和“网络适配器无法建立连接”错误

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

JDBC: Oracle Application Server and "The Network Adapter could not establish the connection" error

javadatabaseoraclejakarta-eeoas

提问by Noah

I am getting the error: "The Network Adapter could not establish the connection" from a web application deployed in Oracle Application Server 10g. The database is local, so there shouldn't be any connection issues.

我收到错误消息:“网络适配器无法建立连接”来自部署在 Oracle 应用服务器 10g 中的 Web 应用程序。数据库是本地的,所以不应该有任何连接问题。

First test: I can connect to the DB no problem from SQL plus, run queries, etc. Second test: I can connect to the database no problem from a locally installed JDeveloper on the server, and run queries, etc. no problem. This works with the short JDBC scring, and the long one (shown below).

第一个测试:我可以从 SQL plus 连接到数据库没有问题,运行查询等。 第二个测试:我可以从服务器上本地安装的 JDeveloper 连接到数据库,并运行查询等没有问题。这适用于短 JDBC 脚本和长 JDBC 脚本(如下所示)。

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=abcd)(SERVER=DEDICATED)))

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=abcd)(SERVER=DEDICATED)))

Yet when I run the web app, it gives the above error. It seems too generic for me to do anything about.

然而,当我运行网络应用程序时,它给出了上述错误。这对我来说似乎太笼统了,无法做任何事情。

Any suggestions on how to solve this? I assume that Oracle logs failed connection attempts somewhere, but I couldn't find anything relevant in the databases alert.log file.

有关如何解决此问题的任何建议?我假设 Oracle 在某处记录了失败的连接尝试,但我在数据库 alert.log 文件中找不到任何相关内容。

It is possible that the problem is that the application is using an old jsdk, but I would assume that then some version mismatch error would be given instead of a "network connection" message.

问题可能是该应用程序使用的是旧的 jsdk,但我认为会给出一些版本不匹配错误而不是“网络连接”消息。

Edit: I don't know whether this is an OAS problem or a problem with the specific Web Application, I would like to figure this out first, as it seems it should be easy. In WebSphere, there is a "test connection" button to dest data-sources you have added, but it seems there is no such functionality in OAS10? Somehow I think there must be, and I am just missing it because I am not an OAS expert.

编辑:我不知道这是 OAS 问题还是特定 Web 应用程序的问题,我想先弄清楚这一点,因为看起来应该很容易。在 WebSphere 中,有一个“测试连接”按钮可以用于您添加的 dest 数据源,但是 OAS10 中似乎没有这样的功能?不知何故,我认为必须有,我只是想念它,因为我不是美洲国家组织的专家。

Edit 2: I installed JDevelop on a remote machine and connected to the database with no problems, so I know for sure it isn't an issue with the database connectivity itself - it seems like it must be a problem within OAS?

编辑 2:我在远程机器上安装了 JDevelop 并且没有问题地连接到数据库,所以我确定这不是数据库连接本身的问题 - 似乎它必须是 OAS 中的问题?

回答by Adisesha

I faced similar problem(able to connect through client but not web application) with Oracle XE when running with default configuration. Increasing number of sessions and processes solved my problem. Check this http://www.markcallen.com/oracle/oracle-xe-tuning.

在使用默认配置运行时,我遇到了与 Oracle XE 类似的问题(能够通过客户端连接但不能通过 Web 应用程序连接)。越来越多的会话和进程解决了我的问题。检查这个http://www.markcallen.com/oracle/oracle-xe-tuning

回答by Gary Myers

I've had issues with localhost and 127.0.0.1 which go away when using a more definitive host name or address [IE a name that other machines would know the host as.]. I think it was to do with how the name was resolved (eg locally or off to a name server or similar).

我遇到了 localhost 和 127.0.0.1 的问题,当使用更明确的主机名或地址 [IE 其他机器知道主机的名称] 时,它们会消失。我认为这与名称的解析方式有关(例如,本地或名称服务器或类似的名称)。

Not a java person, but is there any way to simply ping localhost/127.0.0.1 from the java and see whether there's a response.

不是 java 人,但有什么方法可以简单地从 java ping localhost/127.0.0.1 并查看是否有响应。

回答by Maqdoom Mohammed

One of the ways to fix the issueis to update Hosts file at WAS Server with entries for DB servers as shown below: 111.222.333.444 serverab.abc.com serverab

解决此问题的方法之一是使用如下所示的 DB 服务器条目更新 WAS 服务器上的主机文件:111.222.333.444 serverab.abc.com serverab

回答by Thilo

I assume that Oracle logs failed connection attempts somewhere

我假设 Oracle 在某处记录了失败的连接尝试

It would show up in listener.log, but with the error you get, it seems doubtful that JDBC could even contact the listener.

它会显示在 listener.log 中,但是由于您得到的错误,JDBC 甚至可以联系侦听器似乎令人怀疑。

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=abcd)(SERVER=DEDICATED)))

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=abcd)(SERVER=DEDICATED)))

Is that the same string you use for the web app?

这是您用于网络应用程序的相同字符串吗?