Monday, September 19, 2016

Error :

Caused by: 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

•         Hostname – xxxxxxxdb41/42
•         Scan – xxxxxxxdb-sc
•         Port – 1525
•         Container DB – Cxxxx06P
•         Pluggable DB – Pxxxxx06

TNS Entry is as below

XXX06 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = hqixxxxdb-sc)(PORT = 1525))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XXXX06)
    )
  )

Solution :


If we are using service name to connect use "/" and in case of SID use ":"


Connect via SERVICE_NAME :
username/password@host:port/SERVICE_NAME


Connect via SID :


username/password@host:port:SID


Url :

Url for application to connect : jdbc:oracle:thin:@xxxxxxxdb-sc:1525/XXXX06