title: oracle.net.ns.NetException :ORA-12505, TNS:listener does not currently know of SID given in connect descriptor in Oracle18c ExpressEdition
body: <p>While trying to connect to oracle 18c using jdbc in java 8 using </p>
  
  <p>"Class.forName("oracle.jdbc.driver.OracleDriver");
          cn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","PL","PL"); "</p>
  
  <p>I get 2 exceptions
  "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"
  "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"</p>
  
  <p>I tried executing "lsnrctl status" &amp; "lsnrctl services" in CMD
  And also checked "D:\db_home\dbhomeXE\network\admin\tnsnames.ora" file and "D:\db_home\dbhomeXE\network\admin\listener.ora"</p>
  
  <p>tnsnames.ora </p>
  
  <pre><code># tnsnames.ora Network Configuration File: D:\db_home\dbhomeXE\NETWORK\ADMIN\tnsnames.ora
  # Generated by Oracle configuration tools.
  
  XE =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      (CONNECT_DATA =
        (SERVER = DEDICATED)
        (SERVICE_NAME = XE)
      )
    )
  
  LISTENER_XE =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
  
  
  ORACLR_CONNECTION_DATA =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      )
      (CONNECT_DATA =
        (SID = CLRExtProc)
        (PRESENTATION = RO)
      )
    )
  </code></pre>
  
  <p>listener.ora</p>
  
  <pre><code># listener.ora Network Configuration File: D:\db_home\dbhomeXE\NETWORK\ADMIN\listener.ora
  # Generated by Oracle configuration tools.
  
  DEFAULT_SERVICE_LISTENER = XE
  
  SID_LIST_LISTENER =
    (SID_LIST =
      (SID_DESC =
        (SID_NAME = CLRExtProc)
        (ORACLE_HOME = D:\db_home\dbhomeXE)
        (PROGRAM = extproc)
        (ENVS = "EXTPROC_DLLS=ONLY:D:\db_home\dbhomeXE\bin\oraclr18.dll")
      )
    )
  
  LISTENER =
    (DESCRIPTION_LIST =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      )
    )
  
  </code></pre>
  
  <p>o/p of lsnrctl services:</p>
  
  <pre><code>
  Copyright (c) 1991, 2018, Oracle.  All rights reserved.
  
  Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
  Services Summary...
  Service "CLRExtProc" has 1 instance(s).
    Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
      Handler(s):
        "DEDICATED" established:0 refused:0
           LOCAL SERVER
  The command completed successfully```
  
  o/p of lsnrctl status:
  ```LSNRCTL for 64-bit Windows: Version 18.0.0.0.0 - Production on 12-SEP-2019 01:34:23
  
  Copyright (c) 1991, 2018, Oracle.  All rights reserved.
  
  Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
  STATUS of the LISTENER
  ------------------------
  Alias                     LISTENER
  Version                   TNSLSNR for 64-bit Windows: Version 18.0.0.0.0 - Production
  Start Date                11-SEP-2019 20:13:48
  Uptime                    0 days 5 hr. 20 min. 39 sec
  Trace Level               off
  Security                  ON: Local OS Authentication
  SNMP                      OFF
  Default Service           XE
  Listener Parameter File   D:\db_home\dbhomeXE\network\admin\listener.ora
  Listener Log File         D:\db_home\diag\tnslsnr\DESKTOP-ARH7AVT\listener\alert\log.xml
  Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=DESKTOP-ARH7AVT)(PORT=1521)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
  Services Summary...
  Service "CLRExtProc" has 1 instance(s).
    Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
  The command completed successfully```
  
  I'm getting 
  
  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
  
  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
  </code></pre>