my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes Problem connecting to database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem connecting to database" Watch "Problem connecting to database" New topic

Problem connecting to database

Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
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 ("jdbcracle: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

Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

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
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

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,
    I agree. Here's the link:
    subject: Problem connecting to database
    It's not a secret anymore!