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

荒凉一梦 提交于 2019-12-10 11:23:28

问题


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?


回答1:


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.




回答2:


I assume that Oracle logs failed connection attempts somewhere

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

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?




回答3:


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.




回答4:


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



来源:https://stackoverflow.com/questions/2219417/jdbc-oracle-application-server-and-the-network-adapter-could-not-establish-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!