Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IO Error: The Network Adapter could not establish the connection

I am new to Oracle, and am trying to run a simple example code with Java, but am getting this error when executing the code.. I am able to start up the listener via CMD and am also able to run SQL Plus. Can anyone give me a hand and tell me what I might be doing wrong?

Update: I am using JDBC.

Database is local, and I actually had it working but it stopped working just today. I'm not really sure why though. Would you mind giving me some procedures to follow by since I don't know much.

like image 237
Strawberry Avatar asked Sep 24 '12 23:09

Strawberry


People also ask

How do you fix IO error the network adapter could not establish the connection?

Restart it with the "lsnrctl start" command or on a Windows OS by starting the listener service. Ensure the correct hostname is specified in listner. ora. Add the hostname and IP address in the hosts file located under C:\Windows\System32\drivers\etc folder.

Why Network Adapter could not establish the connection?

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.

What is IO error in SQL Developer?

This error usually means that one of host, port, sid/service is wrong, or there is a network issue. What is the hostname or IP address of the server where the database is running?

How do I fix error 17002?

First check the tnsnames. ora file and ensure that it points to the correct server and port. If the Forms server is on another machine, test the TNS resolve with tnsping from the command prompt. Finally, check the listener.


2 Answers

Either:

  1. The database isn't running
  2. You got the URL wrong
  3. There is a firewall in the way.

(This strange error message is produced by Oracle's JDBC driver when it can't connect to the database server. 'Network adapter' appears to refer to some component of their code, which isn't very useful. Real network adapters (NICs) don't establish connections at all: TCP protocol stacks do that. It would have been a lot more useful if they had just let the original ConnectException be thrown, or at least used its error message and let it appear in the stack trace.)

like image 200
user207421 Avatar answered Sep 18 '22 06:09

user207421


I had the same problem, and this is how I fixed it. I was using the wrong port for my connection.

private final String DB_URL  = "jdbc:oracle:thin:@localhost:1521:orcll"; // 1521 my wrong port 
  • go to your localhost
  • (my localhost address) : https://localhost:1158/em

  • login

    • user name
    • password
    • connect as --> normal
  • Below 'General' click on LISTENER_localhost

  • look at you port number
    • Net Address (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1522)) Connect to port 1522
  • Edit you connection change port 1521 to 1522.

    • done
like image 25
shams Avatar answered Sep 20 '22 06:09

shams