I have a Java application that works on a DB with Oracle 10g. The server is a Windows Server 2003 R2 SP2. This application every now and then, for no apparent reason, stops working for a few seconds and then starts working again. I did a few tests and ended up in creating a small procedure that connects and disconnects to the DB about 1000 times in a row. The application works perfectly, the time of response is great but at a certain point, when I launched this procedure a few times I start getting this error about 60 times and the connection to the DB becomes blocked for a few seconds and then it goes back to normal:
java.sql.SQLException: Io exception: The Network Adapter could not establish theconnection
I believe I might have hit the spot....but I have no idea why I get this error! It is quite annoying since it happends for an application that a lot of users need to use!
P.s. I get the error both from remote and from the local host, so it appears it is not a networking problem.
In any case the exception indicates some sort of connection failure. Might be a problem of system resources (handles), might be anything. You can't debug problems like this by staring at code in any case. Perhaps database logs can give some clue as to why connections are failing, although if the server is involved I would expect exceptions of the 'rejected' or 'reset by peer' variant.
Once again I will state that this idiotic message needs to be removed and replaced by the actual text of the IOException that caused it, so that people like this poster could see what the actual problem is. Network adapters in the form of NICs do not establish connections: TCP/IP protocol stacks do; and if 'network adapter' refers to a software component inside Oracle's JDBC code it is of no interest to outsiders. Unlike the IOException text ('connection refused', 'connection timed out', 'no route to host', etc).
I just looked at the code and the only place that message is used the constructed exception has the original exception set as the cause. So the underlying cause is available to the user. There could have been multiple exceptions in which case only the last is given as the cause. The code also handles the case where the failure isn't caused by an exception, hence no cause, though it's not obvious how that could actually happen.
Very good, thanks for looking, but the fact remains that the error message is meaningless, or should I say content-free, and indeed misleading. A quick search of this forum will show many stack traces with this message where the underlying exception never appeared at all, and where to all appearances the poster never resolved the problem, simply as a consequence of this poor design. It will also reveal several prior instances of my rant.
@OP please post the full stack trace including all nested exceptions.