0

Please help me.I have installed Oracle 11.2.0 g on Windows 7 (32 bit) and I'm trying to connect database with jdk 1.7 I get an error saying

---exception
java.sql.SQLRecoverableException:IO Error: The Network Adapter could not establish the connection

ORACLE_HOME=E:\app\OraDhanya\product\11.2.0\dbhome_1

CLASSPATH=E:\app\OraDhanya\product\11.2.0\dbhome_1\jdbc\lib\*;C:\Program Files\Java\jdk1.7.0_03\bin

Path=E:\app\OraDhanya\product\11.2.0\dbhome_1\BIN;C:\Program Files\Java\jdk1.7.0_03\bin;

Global Database Name =orcldhamanoj.168.1.100
SID=orcldhaman

CODE:

try{
  DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  System.out.println("Connecting to Database");

  Connection cn=DriverManager.getConnection("jdbc:oracle:thin:@orcldhamanoj:1521:orcldhaman","SCOTT","Tiger1");
  System.out.println("Connected to Database");

  Statement st=cn.createStatement();
  st.executeUpdate("create table User(UserID number(3), UserName varchar2(20));");
  System.out.println("Table Created");


  st.close();
  cn.close();
}
catch (SQLException e)
{ 
   System.out.println("exception"+e); 
}
3
  • 1
    Can you connect to server: orcldhamanoj on port: 1521 with sid: orcldhaman? using regular database IDE? its not your code, like the error message said, u can not establish connection. Check your user name and password also. Commented Mar 15, 2012 at 14:45
  • Try using the connection parameters on a client like sql developer to see if that works fine Commented Mar 15, 2012 at 15:22
  • @ Churk,@bluesman---I uninstalled Oracle and while reinstalling I get database Configuration Assistant warning-Enterprise manager configuration failed due to foll. error:Listener is not up or database service is not registered with it.Start the Listener and register database service and run EM Configuration assistant again.Please guide me how to proceed Commented Mar 17, 2012 at 5:51

3 Answers 3

1

The error has nothing to do with JDBC, it's a low level error that tells you the networking layer cannot make a connection to the machine your Oracle server is running on. Causes can be multiple:

  • Wrong connection parameters (ip / host name/ port). This is probably the most frequent cause. Check the ip / hostname using ping, and the port using "telnet [ip/hostname] port" command;
  • Something wrong with your network like a cable problem or wrong network settings.
Sign up to request clarification or add additional context in comments.

Comments

0

In the DriverManager.getConnection method, make sure you specify the IP address of the machine on which Oracle is running -- or localhost if its your current machine.

DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcldhaman","SCOTT","Tiger1");
                                           // ^^^^^^^^^ <-- Or this could be an IP address

Comments

0

I would suggest the following may be causing this kind of error:

  1. (obvious) IP address is incorrect - try PING
  2. The port is not open, or is blocked by a firewall - try TELNET
  3. The DB listener is not running or is binding to a different network interface - again, TELNET should confirm this (also use Oracle client tools to connect)
  4. No local ports are available for the out-going connection (unlikely) - only if you're making thousands of connections, or creating hundreds of new connections every minute.

1 Comment

@user1127214----I uninstalled Oracle and while reinstalling I get database Configuration Assistant warning-Enterprise manager configuration failed due to foll. error:Listener is not up or database service is not registered with it.Start the Listener and register database service and run EM Configuration assistant again.Please guide me how to proceed..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.