我从 Oracle 应用服务器 10g 中部署的 Web 应用程序收到错误:“网络适配器无法建立连接”。数据库是本地的,因此不应该有任何连接问题。
第一个测试:我可以从 SQL plus 连接到数据库,运行查询等,没有任何问题。
第二次测试:我可以从服务器上本地安装的 JDeveloper 连接到数据库,并运行查询等,没有问题。这适用于短 JDBC scring 和长 JDBC scring(如下所示)。
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=abcd)(SERVER=DEDICATED)))
然而当我运行网络应用程序,它给出了上述错误。这对我来说似乎太普通了,无能为力。
关于如何解决这个问题有什么建议吗?我假设 Oracle 在某处记录了失败的连接尝试,但我在数据库alert.log 文件中找不到任何相关内容。
问题可能是应用程序正在使用旧的 jsdk,但我假设会给出一些版本不匹配错误,而不是“网络连接”消息。
编辑:我不知道这是 OAS 问题还是特定 Web 应用程序的问题,我想首先解决这个问题,因为看起来应该很容易。在WebSphere中,有一个“测试连接”按钮可以连接到您添加的目标数据源,但OAS10中似乎没有这样的功能?不知怎的,我认为一定有,但我只是错过了它,因为我不是美洲国家组织的专家。
编辑 2:我在远程计算机上安装了 JDevelop 并连接到数据库,没有任何问题,所以我确信这不是数据库连接本身的问题 - 看起来它一定是 OAS 内的问题?
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.
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).
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.
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.
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.
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?
发布评论
评论(4)
使用默认配置运行时,我在 Oracle XE 中遇到了类似的问题(能够通过客户端连接,但不能通过 Web 应用程序连接)。越来越多的会话和进程解决了我的问题。检查这个http://www.markcallen.com/oracle/oracle-xe-tuning< /a>.
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.
它会显示在listener.log 中,但是根据您收到的错误,似乎 JDBC 是否可以联系侦听器似乎值得怀疑。
是这样吗与您用于网络应用程序的字符串相同吗?
It would show up in listener.log, but with the error you get, it seems doubtful that JDBC could even contact the listener.
Is that the same string you use for the web app?
我遇到了 localhost 和 127.0.0.1 的问题,当使用更明确的主机名或地址时,这些问题就会消失[即其他计算机将主机识别为的名称。]。我认为这与名称的解析方式有关(例如本地或解析到名称服务器或类似服务器)。
不是java人,但是有什么方法可以简单地从java中ping localhost/127.0.0.1并查看是否有响应。
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).
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.
解决该问题的方法之一是使用数据库服务器的条目更新 WAS 服务器上的主机文件,如下所示:
111.222.333.444 serverab.abc.com
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