• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Problem connecting to database

 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am getting the following exception while connecting to databse.

1. driver is loaded
2. Database server is running
what can be the problem. i gave ip address instead of machine name in place of URL

the code is:

Class.forName("oracle.jdbc.driver.OracleDriver");//works fine
System.out.println("Oracle driver loaded: ");
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@mats:1521:ORCL", "system", "orcl");
System.out.println("Connecting to oracle database: ");

The Exception is:

java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
 
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you ping the IP address and connect on that port? You might have a proxy or something blocking that port. Any firewalls?

-Cameron McKenzie
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mathews,
When I did an Internet search on your error message I got over 4,000 hits.
Did none of them answer your question?
The cause of the error is usually one (or more) of the following:
  • Database server is not running.
  • Database connection listener is not running.
  • Connection URL is incorrect.

  • Check first one via SQL*Plus.
    Check second one via "lsnrctl" utility.
    Refer to documentation for correct syntax of third one and then check TNS configuration to verify the correct parameters required.

    Good Luck,
    Avi.
     
    Hang a left on main. Then read this tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
      Bookmark Topic Watch Topic
    • New Topic