File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes java.sql.SQLException: 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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: Io exception: The Network Adapter could not establish the connection" Watch "java.sql.SQLException: Io exception: The Network Adapter could not establish the connection" New topic
Author

java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

smita atagur
Greenhorn

Joined: Feb 23, 2012
Posts: 3
While running the my application i am getting the exception as shown below , actually the application has to get the some data from oracle db for fetchning the data ,as i am newbie please anyone help it out on this how i need to resolve ,its very urgent:
java.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:439)
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:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at org.ltk.sop.Dbconnection.DbHelperOracleProd.mkCon(DbHelperOracleProd.java:29)
Deepak Rao
Ranch Hand

Joined: Jan 24, 2012
Posts: 31

Hi Smita,

Are you able to connect to the DB through any DB client without JDBC?

Thanks
Deepak
smita atagur
Greenhorn

Joined: Feb 23, 2012
Posts: 3
Thanks for the rply ....Yes i am able to connect to the oracle db through TOAD and even to the mysql db. as this application using both the db mysql & TOAD.
Deepak Rao
Ranch Hand

Joined: Jan 24, 2012
Posts: 31

Ok So you are using both Oracle and MySQL.
Are you able to connect to MySQL through your program?
Please check if you are using the right drivers for Oracle?
You can also post a small code snippet ,just as to how you are trying to connect. It will be useful for people to help you.

Thanks
Deepak
Carlo Moore
Greenhorn

Joined: Aug 02, 2005
Posts: 27
I think it might be a problem connecting to two different datasources using one driver.
Which driver are you using? Can you connect to either of the datasources from your application?
Do you have multiple getConnection() methods returning different DataSource objects from your source?
smita atagur
Greenhorn

Joined: Feb 23, 2012
Posts: 3
i am connecting the oracle db by using this java class:

and in the same manner i am connecting to the mysql db also ,totally i wrote two java class one for mysql db connection and another for oracle db , actual i earlier i was able to get the data n able to connect but now this type of error i am getting when i checked the log file .
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

Please UseCodeTags next time. I've added them for you this time.

I'm missing the database name in that URL. What happens if you add it?

And please EaseUp next time. There is no such thing as urgent around here.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Carlo Moore
Greenhorn

Joined: Aug 02, 2005
Posts: 27
The looks a bit strange. I would definitely change some of those methods to private. The close() for instance. When you call your fetch method, you can create a connection, run your sql, and then close right afterwards.
Normally you should check if the ResultSet, Statement and Connection are null before trying to close them and put it in a finally block. What if your rs.close throws an exception? The st.close() and con.close() are never called.


Have you tried using the oci oracle drivers rather than the thin client?


Edit: Just adding a link for ORA JDBC FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection