ORA-12154: TNS:could not resolve service name

Problem

When trying to connect to Oracle, you get this error:

ORA-12154: TNS:could not resolve service name

This error indicates that the service (or TNS alias) specified when trying to connect does not exist.  ‘TNS aliases’ or ‘service names’ are defined locally to each workstation. Thus different workstations could have a completely different alias to refer to the same database.

Solution

Check which aliases are defined on the workstation, and either use one that is defined or add an appropriate one. 

The following methods can be used to view the TNS names:

If a connection alias is not being explicitly provided then try to identify what alias Oracle thinks you are using. This will typically be contained in the ‘sqlnet.log’ file that the Oracle client will produce. Possible places where Oracle could be getting this (default) alias from:

See Also - Oracle

http://forums.oracle.com/forums/thread.jsp?forum=61&thread=267600&message=808024

http://forums.oracle.com/forums/thread.jsp?forum=57&thread=297696&message=&tstart=0&trange=15937179

http://www.cryer.co.uk/brian/oracle/ORA12154.htm

http://www.experts-exchange.com/Databases/Oracle/Q_20902239.html

http://www.dbforums.com/archive/index.php/t-1012623.html

See Also

Part VII:  Troubleshooting Applications

Application Will Not Run

Application Runs But No Data is Displayed

Application Error Messages