• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Io Exception: The Network Adapter could not establish the connection

 
coco huang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Michael Cassidy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
obviously the is an 'at' symbol
[ April 09, 2004: Message edited by: Michael Cassidy ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
coco huang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic