ORA-12154无法解析指定的连接标识符 [英] ORA-12154 could not resolve the connect identifier specified

查看:115
本文介绍了ORA-12154无法解析指定的连接标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已切换到64位Windows 7,并创建了一个简单的Web应用程序来测试与数据库的连接.我正在使用VS 2010-简单的asp.net Web项目,并且正在VS中运行该应用程序.

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.

我收到此错误: "ORA-12154无法解析指定的连接标识符"

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.

在对它们进行一些谷歌搜索之后,我发现很多在线文章都提到了权限,因此我将C:/Oracle权限设置为对ASP.net帐户,网络服务,计算机名进行读取/写入/执行.那仍然无法解决问题.我检查了我的Web应用程序是否在我的domain \ username帐户下运行,并且检查了该帐户是否具有对C:\ Oracle文件夹的读/写/执行权限.

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.

我什至重新安装了VS,以确保它位于C:\ Program Files,而不是C:\ Program Files(x86)

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

关于为什么我的Web应用程序看不到连接字符串的任何想法? (同时控制台应用程序执行) 不知道我还能做什么.

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.

推荐答案

我将假设您正在使用tnsnames.ora文件指定可用的数据库服务.如果是这样,则连接错误通常可归结为两点.

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. 应用程序找不到在连接字符串中指定的TNS条目.

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

已找到TNS条目,但tnsnames.ora文件中的IP或主机不正确.

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

扩大数字1(我认为这是您的问题).当您告诉Oracle使用类似以下内容进行连接时:

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

sqlplus user/pass@service

该服务在tnsnames.ora文件中定义.如果我尝试连接tnsnames.ora中未定义的服务,则会收到错误消息:

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

[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. 是否存在tnsnames.ora文件-我认为可以,因为您的控制台可以连接
  2. 该服务的文件中是否有一个条目-我认为控制台连接也可以
  3. 应用程序可以找到tnsnames.ora吗?

您的问题很可能是问题3-应用程序是否以与运行控制台时不同的用户身份运行?

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

Oracle在TNS_ADMIN环境变量定义的目录中查找tnsnames.ora文件-如果以其他用户身份运行,则可能未设置TNS_ADMIN环境变量,因此找不到该文件?

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?

这篇关于ORA-12154无法解析指定的连接标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆