This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes Io Exception: The Network Adapter could not establish the connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Io Exception: The Network Adapter could not establish the connection" Watch "Io Exception: The Network Adapter could not establish the connection" New topic
Author

Io Exception: The Network Adapter could not establish the connection

coco huang
Greenhorn

Joined: Sep 14, 2003
Posts: 4
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:@//202.201.57.134:1521/myoracle","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?


coco
Michael Cassidy
Greenhorn

Joined: Aug 26, 2003
Posts: 2
Try
DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver());
Connection connection = DriverManager.getConnection("jdbc racle:thin:@202.201.57:1521:myoracle","USER","PASSWORD");
Michael Cassidy
Greenhorn

Joined: Aug 26, 2003
Posts: 2
obviously the is an 'at' symbol
[ April 09, 2004: Message edited by: Michael Cassidy ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

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).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
coco huang
Greenhorn

Joined: Sep 14, 2003
Posts: 4
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?
Greg T Robertson
Ranch Hand

Joined: Nov 18, 2003
Posts: 91
Are you sure you can get to the IP address? Ping 202.201.57.134 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).
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by Michael Cassidy:
Try
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
DriverManager.getConnection("jdbcracle:thin:@202.201.57:1521:myoracle","USER","PASSWORD");
Also, make sure the database is up and running on the server ( aka, can connect using SQL plus or some other tool)
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
Hi,
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
Saritha
rajusaravanan
Greenhorn

Joined: Jul 26, 2002
Posts: 2
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

"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.

Thanks!
bear
Forum Bartender
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
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
Saritha
Michael Debro
Greenhorn

Joined: Mar 14, 2003
Posts: 1
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.

Changed:
jdbc racle:thin:username/password@123.123.123.123:1521:mySID

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

[edited to disable smilies]
[ November 18, 2004: Message edited by: Jeanne Boyarsky ]
Ross Gayle
Greenhorn

Joined: Jan 17, 2004
Posts: 14
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

thx,

Ross
Ram Kumar Subramaniam
Ranch Hand

Joined: Jan 17, 2003
Posts: 68
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 ?
vigneswaran murugesan
Greenhorn

Joined: Mar 02, 2011
Posts: 1
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
Jason Casey
Greenhorn

Joined: Feb 15, 2011
Posts: 4
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.
Sachin Dharayan
Greenhorn

Joined: Jan 04, 2012
Posts: 1
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)
Muhammad Haris
Greenhorn

Joined: Feb 05, 2012
Posts: 1
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
cmd
in
start menu's
run program
, then typing
lsnrctl start
in command prompt window. Haris
 
 
subject: Io Exception: The Network Adapter could not establish the connection