Oracle SQL is an Integrated Development Environment that was created for working on Oracle Databases with SQL. This product is developed and provided by Oracle corporation for free and it is based on the Java Development Kit. Quite recently, there have been many reports of an “IO Error: The Network Adapter Could Not Establish The Connection” Error while testing a database connection.
What Causes the “The Network Adapter Could Not Establish The Connection” Error?
After receiving numerous reports from multiple users, we decided to investigate the issue and devised a set of solutions to fix it completely. Also, we looked into the reasons due to which this error is triggered and listed them as follows.
- Incorrect Details: Make sure that the connection details have been entered properly. The Hostname, Port, Username, and password need to be entered correctly in order to establish the connection. If any of these values aren’t entered properly, the error might be triggered.
- Disabled Service: It is very important that the listener service has been started in the background for the application to work properly, If it hasn’t been started or is disabled, this error might be triggered.
Now that you have a basic understanding of the nature of the problem, we will move on towards the solutions. Make sure to implement these in the specific way in which they are presented to avoid conflict.
Solution 1: Checking Details
It is important that the correct details have been entered for the connection. Sometimes, the details entered don’t match the server configurations and the error is triggered. Therefore, in this step, we will be checking and entering the details again. For that:
- Download and install Notepad++ from here.
- Navigate to the following address.
DB Home: C:/app/Username/product/11.2.0(version might differ)/dbhome_1/Network/Admin
Navigating to the address - Right-click on the “tnsnames.ora” file and select “Open With Notepad ++” option.
Right-clicking on the file and selecting “Open With Notepad++” - Under the “ORCL=” heading, note the “Port” and the “Host” details.
- Also, note the “Service Name“.
Noting down the details - Enter these details while establishing the network connection and click on “Test“.
- Check to see if the issue is solved.
Solution 2: Starting Listener Service
It is possible that the listener service hasn’t been started. This service is required by the application in order to establish a connection. Therefore, in this step, we will be starting the service by entering a command in the Command prompt. For that:
- Press “Windows” + “R” to open the Run prompt.
- Type in “Cmd” and press “Shift” + “Ctrl” + “Enter” to provide adminsitrative privileges.
Typing cmd in the Run Prompt and pressing “Shift”+ “Ctrl” + “Enter” - Type in the following command to check if the service is started.
lsnrctl status
- If the result is similar to the image below, it means that the service hasn’t been started.
This message is displayed if the service hasn’t been started - Enter the following command to start the service manually.
lsnrctl start
Typing in the command to start the service - Now that the listener service has been started, open the application and check to see if a new connection can be established.
Kevin Arrows
Kevin is a dynamic and self-motivated information technology professional, with a Thorough knowledge of all facets pertaining to network infrastructure design, implementation and administration. Superior record of delivering simultaneous large-scale mission critical projects on time and under budget.
Back to top button
OS: CentOS7, ojdbc7.jar, Oracle11g,
and, i didnot installed oracle-client on my host but copied necessary files and libs to able connect to oracle. I tested connection with sqldeveloper and sqlplus, they are OK!
i useing below oracle URL in my properties file
sql.connection=jdbc:oracle:thin://IP:Port/SID
and this command to run
java -cp "./CouchbaseSqlImporter.jar:./ojdbc7.jar" com.couchbase.util.SqlImporter import.properties;
but i faced below Exception:
COUCHBASE SQL IMPORTER
Importing table(s)
from : jdbc:oracle:thin://10.200.6.253:1521/focusdb
to : [http://localhost:8091] — default
Exporting Table : focuscities
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:743)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:666)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:566)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.couchbase.util.SqlImporter.getConnection(SqlImporter.java:397)
at com.couchbase.util.SqlImporter.createViewsForPrimaryKey(SqlImporter.java:294)
at com.couchbase.util.SqlImporter.importTable(SqlImporter.java:216)
at com.couchbase.util.SqlImporter.importData(SqlImporter.java:192)
at com.couchbase.util.SqlImporter.main(SqlImporter.java:87)
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:470)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:506)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:595)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:230)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1452)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:496)
… 10 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:161)
at oracle.net.nt.ConnOption.connect(ConnOption.java:159)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:428)
… 15 more
IO Error: The Network Adapter could not establish the connection
Create Couchbase views for ‘types’ ….
com.couchbase.client.vbucket.ConnectionException: Connection URI is either incorrect or invalid as it cannot be parsed.
at com.couchbase.client.vbucket.config.ConfigurationParserJSON.parseBase(ConfigurationParserJSON.java:59)
at com.couchbase.client.vbucket.ConfigurationProviderHTTP.readPools(ConfigurationProviderHTTP.java:216)
at com.couchbase.client.vbucket.ConfigurationProviderHTTP.getBucketConfiguration(ConfigurationProviderHTTP.java:147)
at com.couchbase.client.CouchbaseConnectionFactory.getVBucketConfig(CouchbaseConnectionFactory.java:231)
at com.couchbase.client.CouchbaseClient.(CouchbaseClient.java:237)
at com.couchbase.client.CouchbaseClient.(CouchbaseClient.java:175)
at com.couchbase.util.SqlImporter.getCouchbaseClient(SqlImporter.java:384)
at com.couchbase.util.SqlImporter.createTableViews(SqlImporter.java:377)
at com.couchbase.util.SqlImporter.importData(SqlImporter.java:197)
at com.couchbase.util.SqlImporter.main(SqlImporter.java:87)
Problem
When the IBM® Rational® Build Forge® Reports or Services layer cannot connect to the database, an error is returned, []java.sql.SQLException: Io exception: The Network Adapter could not establish the connection[].
Symptom
Apache will return a
HTTP Status 500
indicating there is an internal error within tomcat.
The catalina* logs will show the following errors:
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:11 2)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:14 6)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:25 5)
oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:420 )
Cause
This error is caused by a communications failure due to incorrect data in the buildforge.conf file located in $CATALINA_HOME.
Resolving The Problem
Correct the db_host and db_tcp_port entries to match those used by the database to resolve the issue.
[{«Product»:{«code»:»SSB2MV»,»label»:»Rational Build Forge»},»Business Unit»:{«code»:»BU053″,»label»:»Cloud & Data Platform»},»Component»:»User Interface: Reports»,»Platform»:[{«code»:»PF002″,»label»:»AIX»},{«code»:»PF016″,»label»:»Linux»},{«code»:»PF027″,»label»:»Solaris»},{«code»:»PF033″,»label»:»Windows»}],»Version»:»7.0.2″,»Edition»:»Enterprise;Standard»,»Line of Business»:{«code»:»LOB45″,»label»:»Automation»}}]
Hey guys! Have you ever faced the TNS IO error saying “The network adapter could not establish the connection”? when you are trying to make a new connection in SQL Developer or logging on to the database using SQL*Plus editor. If yes then you are at the right place because here in this blog I am going to show you how you can solve this error.
So without further ado let’s proceed to solve this badass TNS error.
Step 1: Make sure your entries are correct
First of all to solve “The network adapter could not establish the connection” error, check whether you have entered the correct username and password as well as the correct Hostname and Port number. Though these are small things we cannot avoid them. After all “It’s the small things in a relationship that means the most.”
[bctt tweet=”How to solve “The network adapter could not establish the connection” error in just 2 steps” username=”RebellionRider”]
For the valid hostname and port number, you can check the Listener.ora if you have access to your server as the listener is a server process. In case you don’t have access to listener.ora file then you can check the tnsnames.ora file.
In case of Listener.ora file check for Host and Port entry in Listener tag for valid hostname and port number.
Listener.ora
And if you are using TNSnames.ora file for validating the hostname and port number then search for the entry which has the same name as your SID and then check for host and port number entry in that particular tag.
TNSnames.ora
Now try connecting. If this solves your problem then you can avoid the next step. But if “The network adapter could not establish the connection” error is still there, then don’t worry just follow the next step.
Step 2: Is your listener taking a rest?
If your problem is still there and you haven’t gotten rid of that nasty error then there is a possibility that your Listener is not running. To check whether Listener is up and running or not, simply open up your command prompt with Administrative privileges and Write
C:> lsnrctl status
This command will show you the status of your listener. If the output of this command looks like the one shown in the picture below then it clearly means your listener is not running thus next what you have to do is to start the listener.
To start the listener you just have to write
C:> lsnrctl start.
This will start your listener and most probably solve your problem.
Info Byte:
In case you are having problems in starting your listener then try starting “OracleOraDb11g_home1TNSListener” windows service. For that open your Run Command and write services.msc this will open your service panel. Here search for the same and right click to start it.
That’s all you have to do. This must solve the “The network adapter could not establish the connection” error. May the force be with you. Enjoy.
Also, click here to learn how to do initial configuration of Orcale Enterprise Manager to start working with it.
If you find this helpful then please do share it on your social network and help me reach out to more people. Also if you have other queries then reach out to me on my Facebook Page & Twitter. Thanks, guys & have a great day!