0

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";
MT0
  • 143,790
  • 11
  • 59
  • 117

1 Answers1

0

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.

Connor McDonald
  • 10,418
  • 1
  • 11
  • 16
  • Tried User ID=sys;Password = password;DBA Privilege = sysdba;Data Source = //localhost/freepdb1; But getting error: Network Transport: TCP transport address connect failure\n Inner Exception - OracleInternal.Network.NetworkException. sqlnet.ora file does have EZCONNECT – eliza_chris Apr 19 '23 at 06:51