Thursday, December 26, 2013

ORA-12154

You get this error when you try to connect to a database which is not in your tnsnames.ora file as you can see in the example below:
 
I set my TNS_ADMIN variable to the current directory:
 
C:\Users\J0294094>set TNS_Admin=C:\Users\J0294094
 
C:\Users\J0294094>
 
I started with an empty tnsnames.ora file:
 
C:\Users\J0294094>more tnsnames.ora
 
C:\Users\J0294094>
 
I tried to connect to a database but got an ORA-12154:
 
C:\Users\J0294094>sqlplus system@busdpt1
 
SQL*Plus: Release 11.2.0.3.0 Production on Mon Nov 18 11:14:00 2013
 
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
 
Enter password:
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
 
Enter user-name:
 
I added the database’s details to the tnsnames.ora file:
 
C:\Users\J0294094>more tnsnames.ora
BUSDPT1.world=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=zge-mktred-dpd1)(Port=1529)))(CONNECT_DATA=(SID=BUSDPT1)))
 
C:\Users\J0294094>
 
… and the error went away:
 
C:\Users\J0294094>sqlplus system@busdpt1
 
SQL*Plus: Release 11.2.0.3.0 Production on Mon Nov 18 11:20:32 2013
 
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
 
Enter password:
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
SQL>

No comments: