Pluggable Database Connection Using SID

Problem Statement

Lately, there have been some questions post upgrading an oracle database from version 12c to 19c and moving to Multi-tenant architecture. One specific question catches my attention where a third-party application only uses the SID (not service) method as a connection string to connect with the database. It was working fine with 12c legacy architecture as using the SID method we can connect to the specific instance of an oracle database. With Multi-tenant architecture when the application needs to connect to a pluggable database aka PDB, the SID connection can only land the connection in the root container and that too will not function as connection credentials will exist in a pluggable database (unless it's a common user).


Since it's a third-party application, it's not possible to change or enhance the behavior overnight and needed an administrator intervention. An initial look would make you feel there is no solution to this problem, as PDB can only be connected using the service method. 


Error code while making a connection to pluggable database using SID can be "ORA-12505: TNS: listener does not currently know of SID given in connect descriptor" 


Findings

Usually, if you look at listener status where your pluggable database is registered, the PDB database will be registered as a service, not an instance. This instance will be registered with the container database. Oracle provides a parameter USE_SID_AS_SERVICE_<listener_name> = ON, which once set under listener.ora will allow the SID connection for the pluggable database. 


Solution

As mentioned in the finding section above, we can use the below-mentioned parameter to be placed in the listener.ora for the database listener used for PDB connection.



            USE_SID_AS_SERVICE_<listener_name> = ON



This parameter will allow the system identifier (SID) in the connection descriptor to be replaced or interpreted as a service name. This will allow clients using SID as a pluggable database service name to make a connection with the PDB database like they use to do before moving to Multi-tenant architecture.


For Example, the snippet below will show usage of this parameter in listener.ora for pluggable database orcl:


  LISTENER = 

     (DESCRIPTION = 

        (ADDRESS=(protocol = tcp)(HOST=<myhostname.domain>)(port = 1777))

        (CONNECT_DATA=(SERVER=DEDICATED)(SID = <orcl>))

     )

   

   USE_SID_AS_SERVICE_LISTENER = ON


Note: Bounce the listener once the parameter has been placed.



Summary

For some legacy applications, we may need to allow the use of the SID connection descriptor even though connection through the service method is the preferred way. Use of parameter USE_SID_AS_SERVICE_<listener_name> = ON would come to rescue from this situation, but this may not be the case with every application. If they can use a service-based connection, then would suggest modifying the connection to use the service method in place of SID. 


Reference

Oracle Net 12c: How to enable Clients using SID to connect to PDB? (Doc ID 1644355.1)




Comments

  1. one quick question: if i i understand correctly, it would only be possible if we have only 1 PDB in that CDB.

    if we have more than 1 PDB in that CDB then only way to connect is using service name?

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Solve - "WAIT FOR EMON PROCESS NTFNS"

Query Regression - "OR" Transformation Oracle 19c

ORA - 12537: TNS: connection closed