Connecting to an Oracle Pluggable Database using connection string in .NET Core Application

414 Views Asked by At

How can we connect to a pluggable database via connection string in my application?

Pluggable database is created via docker.

How do I specify that I want to connect to a pluggable database and not to cdb? Because am getting lot of metadata tables when connected to cdb.

Can we provide service name as an attribute in connection string? I was able to create a connection for my pdb via sql developer, issue is only when I try from code.

Please let me know if you have any solution

I tried using the following connection string but both throwed some error:

var connection string = "User ID=sys; 
Password = password;
DBA Privilege = sysdba; 
Data Source = freepdb1";

Also tried passing localhost

var connection string = "User ID=sys; 
Password = password;
DBA Privilege = sysdba; 
Data Source = localhost/freepdb1";
1

There are 1 best solutions below

1
Connor McDonald On

Most likely you'll need the EZCONNECT syntax, namely:

Data Source = //localhost/freepdb1

Depending on the Oracle client you are using, check also the sqlnet.ora file to ensure it has something like this:

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

so that EZCONNECT is supported.