title: java.sql.SQLException: IO Exception : The Network adapter could not establish the connection?
body: <p>Hi I am trying to connect with Oracle 11g database using ojdbc14 jar on eclipse kepler with java 8 on windows 7 os. But when I am running the code I am getting the following error. Here is my and the errors accordingly.</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  import java.util.Scanner;
  
      public class JDBCExample {
        public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         System.out.println("enter your databse details");
         System.out.println("user name");
         String uName = sc.next();
         System.out.println("password");
         String pWord = sc.next();
         try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
         } catch (ClassNotFoundException e) {
          e.printStackTrace();
         }
         Connection conn = null;
         try {
          conn = DriverManager.getConnection(
                  "jdbc:oracle:thin:@localhost:1521:orcl", "scott", "tiger");
          // jdbc:oracle:thin:@server:1521:xe
         } catch (SQLException e) {
          e.printStackTrace();
         }
         if (conn != null) {
          System.out.println("Successfully connected to DB");
          } else {
          System.out.println("Failed to connect to DB");
         }
     }
  }
  </code></pre>
  
  <p>And the Errors are as follows.
  <code>java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
      at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
      at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:414)
      at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:165)
      at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
      at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at JDBCExample.main(JDBCExample.java:23)</code></p>