title: Getting "java.sql.SQLException: Io exception: The Network Adapter could not establish the connection"
body: <p>The below is my code. I wanted to connect to Employee table from Oracle. </p>
  
  <pre><code>public static void main(String[] args) {         
      try {
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          Connection connection = DriverManager.getConnection(
                      "jdbc:oracle:thin:@localhost:1521:orcl", "scott", "tiger");
          Statement statement = connection.createStatement();
          ResultSet resultset = statement.executeQuery("select 'Connected' from dual");
          resultset.next();
          String s = resultset.getString(1);
          System.out.println(s);
          statement.close();
          connection.close();
      } catch (Exception e) {
          System.out.println("The exception raised is:" + e);
      }
  }
  </code></pre>
  
  <p>I am always getting  the error as 
  "The exception raised is:java.sql.SQLException: Io exception: The Network Adapter could not establish the connection"</p>
  
  <p>I tried turning off the firewall, but no luck. Could someone please help me in resolving the issue.</p>