Forums Register Login
Io Exception: The Network Adapter could not establish the connection
I am trying to access an Oracle DB sitting on a different LAN through my Java application by using JDBC,and I have the driver(classes12.zip).When I user the url ("jdbc racle:thin:@//","user", "password" ) to get the Connection,I get a SQLException(Io Exception: The Network Adapter could not establish the connection).Why I get the SQLException?
DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver());
Connection connection = DriverManager.getConnection("jdbc racle:thin:@202.201.57:1521:myoracle","USER","PASSWORD");
obviously the is an 'at' symbol
[ April 09, 2004: Message edited by: Michael Cassidy ]
You can avoid the dreaded 'smilie conversion' by clicking the 'disable smilies' checkbox when you submit the reply (you can also go back and edit the reply if you forget the first time).
I try to get the connection from my computer to the oracle sever in the other LAN.
I have Try
DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver());
Connection connection = DriverManager.getConnection("jdbc racle:thin:@202.201.57:1521:myoracle","USER","PASSWORD");
but I get SQLException again(IOException Network Adapter can't establish connection).Maybe the user can not have the privilege to visit the server remotely?
Are you sure you can get to the IP address? Ping and be sure you can get to it without java "in the way" so to speak. Also verify that port 1521 is the correct port. You can always use Oracle's regular tools to see i you can get a connection first, and then work from there (assuming you have them installed).
Originally posted by Michael Cassidy:
DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver());
Connection connection = DriverManager.getConnection("jdbc racle:thin:@202.201.57:1521:myoracle","USER","PASSWORD");

without smilies, it is
Also, make sure the database is up and running on the server ( aka, can connect using SQL plus or some other tool)
Even I am getting same problem. Did u guys were able to solve your problem.
I tried to ping my host and I was getting packets from the host.

I am also able to get the connectivity to the database using sqlplus.

Error Code is 17002

This code worked fine before. I am not sure why I am getting this eception now.

Please help me with this
If your database have been upgraded to new version,please copy the new driver libraries (classes12.jar or so) from database machine to your classpath and try.
"rajusaravanan ",

We're pleased to have you here with us in the JSP forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Forum Bartender
Thank you for your reply.

I am using Oracle 10g application server. configured my database using data-source.xml file. I am looking for datasource using JNDI lookup. I guess Oracle 10g application should have all drivers within it and use respective driver. Even if there is a database upgrade it should take care of it. I was assuming this because, in the application server configuration, I will not configure which driver it should use but just provide a URL and JNDI name.

I would appreciate if you could clarify me on this.

thank you
The solution for my "Io exception: The Network Adapter could not establish the connection" exception was to replace the IP of the database server to the DNS name.

jdbc racle:thin:username/password@

jdbc racle:thin:username/password@server@domain.com:1521:mySID

[edited to disable smilies]
[ November 18, 2004: Message edited by: Jeanne Boyarsky ]
i'm also getting the same error when i try to configure weblogic connection pool. I use Oracle 10g. have the classes12.jar and the 10g ojdbc14.jar set in the CLASSPATH before weblogic.jar as specified in the documentation, but still get the error. i can connect thru' sqlplus.

any help is greatly appreciated


I tried Michael Debro findings and it worked great for the case
a.) when both the appserver and the db are on the same machine.
b.) does not work when the app server and db is on different machines

Have tried different settings. Any idea on why the first option worked ?
the main problem for this error is the listner is not installed in your system or its not started
go to control pannel->administratiove tool->services->oracle listner (some four files strting with oracle see all the four files are in started) if its not started(rightclick and start) try to start it and run the programe it will work if the listener is not started try it by restarting the stystem it will defenetly work
I would suggest the following may be causing this kind of error:

1. (obvious) IP address is incorrect - try PING <ip>
2. The port is not open, or is blocked by a firewall - try TELNET <ip> <port>
3. The DB listener is not running or is binding to a different network interface - again, TELNET should confirm this (also use Oracle client tools to connect)
4. No local ports are available for the out-going connection (unlikely) - only if you're making thousands of connections, or creating hundreds of new connections every minute.

These are first things I would check, then I'd start looking at the application code (checking drivers, confirming the code is doing what I expect). If you're still stuck after that, you can take a look at how this exception is being thrown - see http://www.insideexceptions.com/en/jdk-1-5-0/java-sql-SQLException.html and search the page for "ioexception". From you there you can probably trace the problem into the IOException (http://www.insideexceptions.com/en/jdk-1-5-0/java-io-IOException.html) which is where the real problem seems to be. But if you get to that stage you probably need to be fairly experienced with Java, etc. Usually this kind of error is one of the obvious things listed above.

If you still have problems, I suggest posting the entire exception message here.
Hi Jason ,
It would very kind if you can help me out of this ,we are getting this error while running a batch file from our windows 2003 Application server

Message :Fatal Error in Publish Daemon SQL connection get returned error. Message:Io exception: The Network Adapter could not establish the connection SQLState :[null] ErrorCode : [17002]

Stack Tracejava.sql.SQLException: Io exception: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at com.xyz.abc.util.ConnectionManager.getConnectionForBatch(Unknown Source)
at com.xyz.abc.common.custom.BatchCustom.getConnnectionToHost(Unknown Source)
at com.xyz.abc.batch.alertserver.PublishDaemon.getCurrentDate(Unknown Source)
at com.xyz.abc.batch.alertserver.PublishDaemon.main(Unknown Source)
I had the same problem when trying to connect my oracle database using oracle sql developer, giving the error "the network adapter could not establish the connection". The only thing I did to resolve the error is starting the listener; just start
command prompt
by typing
start menu's
run program
, then typing
lsnrctl start
in command prompt window. Haris
Please check the listener status ? and the ports running on it .
75% of time this error is caused when sql listener is stopped or port conflict .

Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

All times above are in ranch (not your local) time.
The current ranch time is
Jan 21, 2017 03:48:11.