title: Connect Java with Oracle 12c
body: <p>After searching allot I'm still unable to connect java with oracle I used the following program.</p>
  
  <pre><code>import java.sql.DriverManager;
  import java.sql.Connection;
  import java.sql.SQLException;
  public class LoadDriver{
      public static void main(String[] args){
          try{
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection con = DriverManager.getConnection("jdbc:oracle:thin:scott/scott@localhost:1521:pdborcl");
          }catch(SQLException e){
              System.out.println(e.getMessage());
          }catch(ClassNotFoundException e){
              System.out.println("Class Not Found");
          }
      }
  }
  </code></pre>
  
  <p>I'm getting error.</p>
  
  <pre><code>Listener refused the connection with the following error:
  ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
  The Connection descriptor used by the client was:
  localhost:1521:pdborcl
  </code></pre>
  
  <p>Because getConnection throwing <code>SQLException</code> I tried all ways like <code>jdbc:oracle:thin:@localhost:1521:pdborcl</code>,<code>scott</code>,<code>pass</code> but still unable to connect. Can any one help to connect?</p>