Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORA-12154 could not resolve the connect identifier specified

Tags:

asp.net

oracle

I have switched over to the 64bit Windows 7 and created a simple web app to test the connection to the database. I am using VS 2010 - plain asp.net web project and I am running the application from within VS.

I am getting this error: "ORA-12154 could not resolve the connect identifier specified"

I also have a sample console application that tests the connection to the database, and it works fine.

After googling it some, I found that a lot of posts online refered to permissions so I set my C:/Oracle permissions to read/write/execute for my ASP.net account, NETWORK SERVICE, COMPUTER NAME. That still won't solve the issue. I checked that my web app runs under my domain\username account and that this account that the rights to read/write/execute to the C:\Oracle folder.

I even re-installed my VS to make sure that it is in C:\Program Files rather than C:\Program Files(x86)

Any ideas to why my web app doesn't see the connection string? (while the console app does) Not sure what else I can do.

like image 773
sarsnake Avatar asked Oct 31 '11 18:10

sarsnake


People also ask

How do I resolve TNS issue?

Go to the $ORACLE_HOME/network/admin directory and open the tnsnames. ora file and look for the connect identifier, verify that it's correct. You could have a typo or be missing the connection details in the tnsnames. ora file (on windows %ORACLE_HOME%\network\admin).

What is the connect identifier?

A connect identifier can be the connect descriptor or a name that resolves to a connect descriptor. The connect descriptor contains: Network route to the service, including the location of the listener through a protocol address. A database service name or Oracle system identifier (SID)


1 Answers

I am going to assume you are using the tnsnames.ora file to specify your available database services. If so connection errors usually come down to two things.

  1. The application cannot find the TNS entry you specified in the connection string.

  2. The TNS entry was found, but the IP or host is not correct in the tnsnames.ora file.

To expand on number 1 (which I think is your problem). When you tell Oracle to connect using something like:

sqlplus user/pass@service 

The service is defined in the tnsnames.ora file. If I attempt to connect with a service that is not defined in my tnsnames.ora, I get the error you get:

[sodonnel@home ~]$ sqlplus sodonnel/sodonnel@nowhere

SQL*Plus: Release 11.2.0.1.0 Production on Mon Oct 31 21:42:15 2011  Copyright (c) 1982, 2009, Oracle.  All rights reserved.  ERROR: ORA-12154: TNS:could not resolve the connect identifier specified 

So you need to check a few things:

  1. Is there a tnsnames.ora file - I think yes because your console can connect
  2. Is there an entry in the file for the service - I think also yes as the console connects
  3. Can the application find the tnsnames.ora?

Your problem may well be number 3 - does the application run as a different user than when you run the console?

Oracle looks for the tnsnames.ora file in the directory defined in the TNS_ADMIN environment variable - If you are running as different users, then maybe the TNS_ADMIN environment variable is not set, and therefore it cannot find the file?

like image 83
Stephen ODonnell Avatar answered Oct 01 '22 11:10

Stephen ODonnell