I'm new to JDBC & I'm trying to connect to oracle database using traditional oracle drivers. My program works fine & was able to connect and run the queries. While testing my code, after sometime, I got database connection failure due to "The Network Adapter could not establish the connection". Below is the stack trace, what I got.
2014/07/24 14:22:51:461 MDT [TRACE] DatabaseManager - Entering: com.bcn.batchstats.util.DatabaseManager Method: openConnection
2014/07/24 14:22:51:787 MDT [ERROR] DatabaseManager - Error opening Database connection during maxRetries: jdbcracle:thin:@<hostname>:<port>:<SID> <java.sql.SQLException: The Network Adapter could not establish the connection>java.sql.SQLException: The Network Adapter could not establish the connection
at com.org.batchstats.util.DatabaseManager.openConnection(Unknown Source)
at com.org.batchstats.util.AgentConfigurationUtil.fetchAgentConfiguration(Unknown Source)
at com.org.batchstats.util.AgentConfigurationUtil.loadStatsCollectors(Unknown Source)
at com.org.batchstats.StatsAgent.createCollectorThreadList(Unknown Source)
at com.org.batchstats.StatsAgent.main(Unknown Source)
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
... 11 more
Caused by: java.net.UnknownHostException: <hostname>: <hostname>
... 16 more
2014/07/24 14:22:51:789 MDT [TRACE] DatabaseManager - Exiting: com.org.batchstats.util.DatabaseManager Method: openConnection
2014/07/24 14:22:52:291 MDT [FATAL] DatabaseManager - DB connection == null: java.sql.SQLException: The Network Adapter could not establish the connection.
I didn't touch the database part while modifying the code. Its just a date utility that I've worked on & not sure what caused the problem, given that it was working fine after my changes as well. Moreover, I'm able to connect to the same database using SQL developer tool. I check the properties & all the properties are similar. Please help me.
What is the value of "jdbcUrl"? Not what you think it should be, but its actual value. Print it out when you try to make the connection.
Joined: Jun 04, 2012
In the stack trace, I provided in my post.. I've printed the jdbc URL. I check with SQL developer & its working fine. I'm able to connect to the database. So, I believe there is nothing wrong with the jbdc URL. Did I miss something?
Joined: Mar 22, 2005
You mean "jdbc:oracle:thin:@<hostname>:<port>:<databasename>" is the actual value you're using? In that case it's no wonder it's not working - you need to provide valid values for hostname, port and databasename.
Joined: Jun 04, 2012
Thats not the actual values. Anyway thanks for your response. I figured out that the issue is with the hostname. Thats no more in use & hence is not responding and my attempt to connect to it fails.