Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to connect to my friends Oracle server. But while connection I am getting error please help.....

JDBC code


Error Message

java.sql.SQLException: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(
at oracle.jdbc.driver.PhysicalConnection.<init>(
at oracle.jdbc.driver.T4CConnection.<init>(
at oracle.jdbc.driver.T4CDriverExtension.getConnection(
at oracle.jdbc.driver.OracleDriver.connect(
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.wipro.sample.min.main(

    Caused by: The Network Adapter could not establish the connection
   at oracle.jdbc.driver.T4CConnection.connect(
   at oracle.jdbc.driver.T4CConnection.logon(
   ... 7 more

    Caused by: Connection refused: connect
   at Method)
   at Source)
   at Source)
   at Source)
   at Source)
   at Source)
   ... 12 more
share|improve this question

migrated from Feb 12 '10 at 8:05

This question came from our site for professional and enthusiast programmers.

three words: ping, firewall, network administrator – Bozho Feb 12 '10 at 6:55
@Bozho: so what should i do on my friends system to enable the connection... – Hari Feb 12 '10 at 6:59
did you ping? did you check the firewall? – Bozho Feb 12 '10 at 7:01
i pinged the system.. there was no problem...what i have to check in the firewall – Hari Feb 12 '10 at 7:03
BTW, it should be Class.forName ("oracle.jdbc.driver.OracleDriver"); – Pascal Thivent Feb 12 '10 at 7:33
up vote 1 down vote accepted

Looks like oracle server is not listening...

Connect to the machine where oracle is present..

Run su - oracle

lsnrctl status

is listner is not active then do lsnrctl start

share|improve this answer

It seems like you can't connect to Oracle server. First try to telnet your Oracle server by using the Oracle's port.

Ex: telnet <Oracle Serrver IP> 1521

share|improve this answer
Connecting To <ipaddress> Could not open connection to the host, on port 1521: Connect failed – Hari Feb 12 '10 at 7:10
above was the message i recieved when i executed the provided statement – Hari Feb 12 '10 at 7:11
Your oracle server is refusing to connect with your application. Please check firewall configuration in the Oracle server also make sure whether Oracle server is up and running. – Upul Feb 12 '10 at 7:14
how to check the firewall configaration..... – Hari Feb 12 '10 at 7:18
Please follow this tutorial – Upul Feb 12 '10 at 7:26

This error may occure when you:

  1. Try to connect to the different host:port. Double-check your settings.
  2. Oracle server is down. You need to start it.
  3. Your firewall blocks your connection to oracle. You need to allow access for your application.
share|improve this answer

A typical Oracle network setup consists of:

  1. The database instance on the server
  2. As @Abhiram states, a "listener" also runs on the server, waiting for connections, by default on port 1521.
  3. Clients connect to the server on the correct port, the listener hands off the connection to the database instance.

As others have pointed out, (1) the database needs to be up; (2) the listener needs to be running and you need to know what port; (3) firewalls need to be configured to allow traffic on the port, most often on the server side.

Can your friend use an ODBC connection on their system, by way of the listener (not a local connection)? In other words, would your code run on their system?

share|improve this answer

Gusset do following:

  1. ping ip address. If get time out , it means there is network connection problem.
  2. If ping result indicates connection ok, and the still get same exception, then do: use command tracert Ip Address to gat domain name.
  3. use domain name instead of ip addesss in your connection string:

    conn=DriverManager.getConnection(jdbc:oracle:thin:@<domain Name>:<SID>,userName,password);
  4. use DriverManager.registerDriver (new oracle.jdbc.OracleDriver()); instead of Class.forName(oracle.jdbc.driver.OracleDriver).newInstance();
share|improve this answer
This question has been answered nearly 5 years ago and the solution was something else entirely. – Sven Dec 29 '14 at 20:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.