title: JDBC Connection failing with ORA-12505 on Win8, Oracle 11g XE
body: <p>I'm having an error that goes beyond what I see in <a href="https://stackoverflow.com/questions/5661610/tns-12505-tnslistener-does-not-currently-know-of-sid-given-in-connect-descript">TNS-12505: TNS:listener does not currently know of SID given in connect descriptor</a></p>
  
  <p>I'm using Windows 8, Oracle 11.2 XE, java 1.7.15, and Eclipse Juno SR2.</p>
  
  <p>The error I receive is:</p>
  
  <p><em>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</em></p>
  
  <p>I have the driver registered properly, and I've edited the listener.ora to make the service explicit, in both ways I've seen given as exampled - under SID_LIST_LISTENER, I added:</p>
  
  <pre><code>(SID_DESC =
     (SID_NAME = XE)
     (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
  )
  </code></pre>
  
  <p>and under LISTENER = (DESCRIPTION_LIST I added</p>
  
  <pre><code>(DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = XE)
   )
  </code></pre>
  
  <p>tnsnames.ora contains, as its first entry:</p>
  
  <pre><code>XE =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      (CONNECT_DATA =
        (SERVER = DEDICATED)
        (SERVICE_NAME = XE)
      )
    )
  </code></pre>
  
  <p>The source code making the calls is:</p>
  
  <pre><code>Class.forName(JDBC_DRIVER);
  String connectionString = "jdbc:oracle:thin:localhost:1521/XE";
  myConnection = DriverManager.getConnection(connectionString, "myuser", "myuserpw");
  </code></pre>
  
  <p>I've also been through the following permutations on the connectionString. with results noted here:</p>
  
  <pre><code>jdbc:oracle:thin:@localhost:1521:XE // java.sql.SQLException: ORA-01017: invalid username/password; logon denied
  jdbc:oracle:thin:localhost:1521:XE  // error ORA 12505
  jdbc:oracle:thin:@//localhost:1521:XE // error java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
  jdbc:oracle:thin:@localhost:1521/XE // error ORA-01017
  jdbc:oracle:thin:@//localhost:1521/XE // error ORA-01017
  </code></pre>
  
  <p>Anyone have ideas?</p>