Connect to two DB using Oracle wallet without TNS_ADMIN path change

1.3k views Asked by At
-bash-4.1$ export TNS_ADMIN="/tmp/PKI/DB_A"
-bash-4.1$ sqlplus /@DB_A

Connects fine

-bash-4.1$ export TNS_ADMIN="/tmp/PKI/DB_B"
-bash-4.1$ sqlplus /@DB_B

Connects fine

-bash-4.1$ sqlplus /@DB_A

Error logon denied (since the last TNS_ADMIN path points to the DB_A)

There is an option of using TNS Names with the JDBC, i.e. set the oracle.net.TNS_ADMIN property to the directory that contains your tnsnames.ora file ( java -Doracle.net.tns_admin=$ORACLE_HOME/network/admin).

The situation is, I will not be able to change TNS_ADMIN Path. Is there any option in Oracle sqlplus NOT to specify TNS_ADMIN path but seemlessly connect to both DB_A and DB_B ?

1

There are 1 answers

0
Wernfried Domscheit On

You can connect directly to DB like this:

sqlplus /@"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.10.10)(PORT=1521))(CONNECT_DATA=(SERVER= DEDICATED)(SERVICE_NAME=DB_A)))"

i.e. copy the full text from the tnsnames.ora file you like to use. Remove any line breaks for use on command line.