views:

644

answers:

4

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?

A: 

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?

Thilo
Well I tried with that long string, and the short version like:jdbc:oracle:thin:@localhost:1521:abcdBoth work fine on the JDev, and both give the same error with the Web App. I also tried localhost vs. the IP address. Same result- both are fine in JDev, and both throw errors in the app. I am pulling my hair out because I find it difficult to believe that they built OAS without a "test connection" button *somewhere* in the management interface.
Noah
did you get anything in listener.log?
Thilo
The reason I wanted to check the long was to see if the connection was somehow rejected by the listener (though I can't imagine it would be, since it's a local connection).
Noah
+1  A: 

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

Adi
+1 i have had that happen, too. Problem seems to be when using a connection pool that starts out wanting many connections all at once. Are you on Windows?
Thilo
Hmm that was a good suggestion, but looking at the numbers, they seems quite a bit higher than what is in the linked sample. Yes, on Windows 2003.
Noah
SQL> show parameters sessionsNAME TYPE VALUE------------------------------------ ----------- ----------java_max_sessionspace_size integer 0java_soft_sessionspace_limit integer 0license_max_sessions integer 0license_sessions_warning integer 0logmnr_max_persistent_sessions integer 1sessions integer 445shared_server_sessions integer
Noah
<code>SQL> show parameters processesNAME TYPE VALUE------------------------------------ ----------- ----------aq_tm_processes integer 0db_writer_processes integer 1gcs_server_processes integer 0job_queue_processes integer 10log_archive_max_processes integer 2processes integer 400SQL> </code>
Noah
A: 

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.

Gary
Hmm, I will certainly give this a try to see if it helps. If it is such a simple solution, I will feel a bit silly, but be happy to have the problem solved.
Noah
A: 

Hi, we have recently experienced this message when Oracle iAS is connecting to remote database and have spend weeks looking for a cause/solution.

"The Network Adapter could not establish the connection"

Did you find a solution to your problem?

Regards

Rob
The solution was: The app wasn't using the config that gets set in the App Server, but had it's own properties file containing the IP of the database and/or some files actually had hard-coded database references. If it says it can't connect, but you can connect manually, it's probably pointing to the wrong place.
Noah
Thanks for the info. Our app is using JNDI to lookup a datasource, as specified in data-sources.xml. I have tried host name and IP address and both have been deployed to the App Server as expected. This is not a persistent problem but an intermittent irritation – sometimes connection is successful but seconds later error occurs, with no change to connection details.
Rob