This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
smita atagur
Greenhorn
Joined: Feb 23, 2012
Posts: 3
posted
0
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)
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
posted
0
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.
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
posted
0
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
posted
0
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 .
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?