• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Ranch Hand
Posts: 36
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Smita,

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

Thanks
Deepak
 
smita atagur
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
Sheriff
Posts: 22768
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Carlo Moore
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Always! Wait. Never. Shut up. Look at this tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic