44

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.

user3840170
  • 26,597
  • 4
  • 30
  • 62
Strawberry
  • 66,024
  • 56
  • 149
  • 197

13 Answers13

49

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.)

user207421
  • 305,947
  • 44
  • 307
  • 483
9

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
shams
  • 91
  • 1
  • 1
    I got the same problem because I forgot the @ – thoredge Nov 29 '13 at 10:22
  • +1. i had the same problem. I forgot the @. Example: JDBC_STRING="jdbc:oracle:thin:@aravindr-dra0r0.cyrbi4kznovv.us-west-1.rds.amazonaws.com:8195:DRA0R0" – AravindR Jun 13 '18 at 21:49
3

Another thing you might want to check that the listener.ora file matches the way you are trying to connect to the DB. If you were connecting via a localhost reference and your listener.ora file got changed from:

HOST = localhost

to

HOST = 192.168.XX.XX

then this can cause the error that you had unless you update your hosts file to accommodate for this. Someone might have made this change to allow for remote connections to the DB from other machines.

user1827044
  • 176
  • 5
1

I figured out that in my case, my database was in different subnet than the subnet from where i was trying to access the db.

V Gupta
  • 23
  • 1
  • 1
  • 6
1

I had this error when i renamed the pc in the windows-properties. The pc-name must be updated in the listener.ora-file

anion
  • 1,516
  • 1
  • 21
  • 35
1

IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=iKQM6lBbSLiArrYuDqud8A==)

if you are facing this issue 1- make sure you have downloaded oracle databases like oracle 11g,19c, 21c, or any latest databases. 2- search for services in your computer or type win+r then services.mis then search for oracleservice you will find orcl or xe or any other sid like oracleserviceorcl;

after that you can test your connection using sql developer, sql plus or cmd

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 27 '22 at 12:42
0

Most probably you have listener configured wrongly, the hostname you specify in connection string must be the same as in the listener.

First check the Firewall and network related issues.

Check if Oracle Listener service is available and running. If not you may use Oracle Net Configuration Assistant tool to add and register new listener.

If the above steps are ok then you need to configure Oracle Listener appropriately. You may use Oracle Net Manager tool or edit “%ORACLE_HOME%\network\admin\listener.ora” file manually.

There are 2 options that need to be considered carefully: Listening Locations associated with the Listener – Hostname(IP) and Port in Listening Location must exactly match the ones used in the connection string.

For example, if you use 192.168.74.139 as target hostname, then there must be Listening Location registered with the same IP address.

Also make sure the you use the same SID as indicated in Database Service associated with the Listener.

https://adhoctuts.com/fix-oracle-io-error-the-network-adapter-could-not-establish-the-connection-error/

  • Hello. While posting some link is okay, we prefer them being posted with some explanation and some excerpt of the source, please read [answer] and improve your answer. – Baptiste Mille-Mathias Aug 26 '18 at 14:38
0

I resolved my issue by simply starting the TNS listener service. It was stopped for some reason. enter image description here

Serge V.
  • 3,377
  • 3
  • 20
  • 28
-1

To resolve the Network Adapter Error I had to remove the - in the name of the computer name.

Tiago Sippert
  • 1,324
  • 7
  • 24
  • 33
Dharm
  • 1
-1

In my case, I needed to specify a viahost and viauser. Worth trying if you're in a complex system. :)

Kris Selbekk
  • 7,438
  • 7
  • 46
  • 73
-1

For me the basic oracle only was not installed. Please ensure you have oracle installed and then try checking host and port.

Karisa
  • 9
-1

I was having issues with this as well. I was using the jdbc connection string to connect to the database. The hostname was incorrectly configured in the string. I am using Mac, and the same string was being used on Windows machines without an issue. On my connection string, I had to make sure that I had the full url with the appending "organizationname.com" to the end of the hostname.

Hope this helps.

A May
  • 9
  • 3
-2

Just try to re-create connection. In my situation one of jdbc connection stopped working for no reason. From console sqlplus was working ok. It took me 2 hours to realize that If i create the same connection - it works.