title: ORA-12505, TNS:listener does not currently know of SID
body: <p>I'm new to java oracle database coding and I'm getting this error when running the code below (eclipse kepler):</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  
  public class main {
  
      public static void main(String[] args) {
          try {
              Class.forName("oracle.jdbc.OracleDriver");
          } catch (ClassNotFoundException e) {
              e.printStackTrace();
              return;
          }
          Connection connection = null;
          try {
              connection = DriverManager.getConnection(
                      "jdbc:oracle:thin:@10.0.32.166:1521:orcl", "username", "password");
          } catch (SQLException e) {
              e.printStackTrace();
              return;
          }
      }
  }
  </code></pre>
  
  <p>Error is for ojdbc14.jar:</p>
  
  <pre><code>java.sql.SQLException: Listener refused the connection with the following error:
  ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
  
  at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
  at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:389)
  at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:454)
  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:802)
  at java.sql.DriverManager.getConnection(DriverManager.java:571)
  at java.sql.DriverManager.getConnection(DriverManager.java:215)
  at oracle.main.main(main.java:18)
  </code></pre>
  
  <p>While I tried to change ojdbc6.jar but a different error shows up:</p>
  
  <pre><code>java.sql.SQLException: Listener refused the connection with the following error:
  ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
  
  at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
  at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
  at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
  at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:480)
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:413)
  at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:508)
  at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:203)
  at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)
  at java.sql.DriverManager.getConnection(DriverManager.java:571)
  at java.sql.DriverManager.getConnection(DriverManager.java:215)
  at oracle.main.main(main.java:18)
  Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
  ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
  
  at oracle.net.ns.NSProtocol.connect(NSProtocol.java:361)
  at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:966)
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:292)
  ... 7 more
  </code></pre>
  
  <p>Reason I'm experimenting on the 2 jar is I'm not sure which is compatible to jdk 1.6 as this is were I'm gonna deploy (linux env) the executable jar once completed. Need help to identify what these errors are and ideas to fix them? thank you</p>