oracle ora 12154 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/162762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ora 12154 error
提问by Hugo Assanti
I recently deploy one web application in one of my development servers. I'm using oracle, asp.net and c#. When I run the application in the server everything works fine, but when I try to run the application outside of the server (using my pc, for example) i get this error:
我最近在我的一台开发服务器上部署了一个 Web 应用程序。我正在使用 oracle、asp.net 和 c#。当我在服务器中运行应用程序时一切正常,但是当我尝试在服务器外部运行应用程序时(例如使用我的电脑),我收到此错误:
ORA-12154: TNS:could not resolve the connect identifier specified
If i run the application in my pc with visual studio it works fine.
如果我使用 Visual Studio 在我的电脑上运行该应用程序,它就可以正常工作。
Oracle is installed in Server "A" and the application is in server "B". Server "A" is in one domain and server "B" is in other domain.My pc is in the same domain has Server "A".
Oracle 安装在服务器“A”中,应用程序安装在服务器“B”中。服务器“A”在一个域中,服务器“B”在另一个域中。我的电脑在同一个域中有服务器“A”。
In my pc I can find the file tnsname.ora in C:\oracle\product\10.2.0\client_1\NETWORK\ADMIN, but in Server "B" i can′t find it anywhere
在我的电脑中,我可以在 C:\oracle\product\10.2.0\client_1\NETWORK\ADMIN 中找到文件 tnsname.ora,但在服务器“B”中我找不到它
any idea? Thanks for the help.
任何的想法?谢谢您的帮助。
采纳答案by George Mauer
Guess: An oracle client is not installed on Server B.
猜测:服务器B上没有安装oracle客户端。
If you do have an oracle client installed then you can still put a tnsnames file in any location (Such as a directory on a network share). In order to do this, set a TNS_ADMIN system variable (System Properties->Advanced->Environment Variables on XP) to the directory containing your tnsnames files.
如果您确实安装了 oracle 客户端,那么您仍然可以将 tnsnames 文件放在任何位置(例如网络共享上的目录)。为此,请将 TNS_ADMIN 系统变量(XP 上的系统属性->高级->环境变量)设置为包含 tnsnames 文件的目录。
For me for example I have a system variable: TNS_ADMIN - C:\oracle\ora92\network\ADMIN
以我为例,我有一个系统变量:TNS_ADMIN - C:\oracle\ora92\network\ADMIN
回答by warren
Have you tried this yet? (from http://ora-12154.ora-code.com/)
你有没有试过这个?(来自http://ora-12154.ora-code.com/)
ORA-12154: TNS:could not resolve the connect identifier specified
Cause: A connection to a database or other service was requested using a connect identifier, and the connect identifier specified could not be resolved into a connect descriptor using one of the naming methods configured. For example, if the type of connect identifier used was a net service name then the net service name could not be found in a naming method repository, or the repository could not be located or reached.
Action:
- If you are using local naming (TNSNAMES.ORA file):
ORA-12154:TNS:无法解析指定的连接标识符
原因:使用连接标识符请求到数据库或其他服务的连接,并且使用配置的命名方法之一无法将指定的连接标识符解析为连接描述符. 例如,如果使用的连接标识符类型是网络服务名称,则无法在命名方法存储库中找到该网络服务名称,或者无法定位或访问该存储库。
操作: - 如果您使用本地命名(TNSNAMES.ORA 文件):
Make sure that "TNSNAMES" is listed as one of the values of the NAMES.DIRECTORY_PATH parameter in the Oracle Net profile (SQLNET.ORA)
Verify that a TNSNAMES.ORA file exists and is in the proper directory and is accessible.
Check that the net service name used as the connect identifier exists in the TNSNAMES.ORA file.
Make sure there are no syntax errors anywhere in the TNSNAMES.ORA file. Look for unmatched parentheses or stray characters. Errors in a TNSNAMES.ORA file may make it unusable.
If you are using directory naming:
Verify that "LDAP" is listed as one of the values of the NAMES.DIRETORY_PATH parameter in the Oracle Net profile (SQLNET.ORA).
Verify that the LDAP directory server is up and that it is accessible.
Verify that the net service name or database name used as the connect identifier is configured in the directory.
Verify that the default context being used is correct by specifying a fully qualified net service name or a full LDAP DN as the connect identifier
If you are using easy connect naming:
Verify that "EZCONNECT" is listed as one of the values of the NAMES.DIRETORY_PATH parameter in the Oracle Net profile (SQLNET.ORA).
Make sure the host, port and service name specified are correct.
Try enclosing the connect identifier in quote marks. See the Oracle Net Services Administrators Guide or the Oracle operating system specific guide for more information on naming.
确保“TNSNAMES”被列为 Oracle Net 配置文件 (SQLNET.ORA) 中 NAMES.DIRECTORY_PATH 参数的值之一
验证 TNSNAMES.ORA 文件是否存在并且位于正确的目录中并且可以访问。
检查用作连接标识符的网络服务名称是否存在于 TNSNAMES.ORA 文件中。
确保 TNSNAMES.ORA 文件中的任何地方都没有语法错误。查找不匹配的括号或杂散字符。TNSNAMES.ORA 文件中的错误可能会使其无法使用。
如果您使用目录命名:
验证“LDAP”是否被列为 Oracle Net 配置文件 (SQLNET.ORA) 中 NAMES.DIRETORY_PATH 参数的值之一。
验证 LDAP 目录服务器是否已启动并且可以访问。
验证用作连接标识符的网络服务名称或数据库名称是否已在目录中配置。
通过指定完全限定的网络服务名称或完整的 LDAP DN 作为连接标识符来验证所使用的默认上下文是否正确
如果您使用简单的连接命名:
验证“EZCONNECT”是否被列为 Oracle 网络配置文件 (SQLNET.ORA) 中 NAMES.DIRETORY_PATH 参数的值之一。
确保指定的主机、端口和服务名称正确。
尝试将连接标识符括在引号中。有关命名的更多信息,请参阅 Oracle 网络服务管理员指南或 Oracle 操作系统特定指南。
回答by Thomas Jones-Low
Resolving TNS errors can be a real pain. A few things to keep in mind.
解决 TNS 错误可能是一个真正的痛苦。有几件事要记住。
Most development environments (like visual studio) keep their own copy of the TNS connection information, and do not use the TNSNAMES.ora file. The file where this information is kept does not have to be called TNSNAMES.ora, that's just the default name. Which may be the reason you can't find it on Server B.
大多数开发环境(如 Visual Studio)保留自己的 TNS 连接信息副本,并且不使用 TNSNAMES.ora 文件。保存此信息的文件不必称为 TNSNAMES.ora,这只是默认名称。这可能是您在服务器 B 上找不到它的原因。
If you have the oracle client software (or an oracle database) you can use tnspingto check if your TNSNAMES.ora file is configured correctly.
如果您有 oracle 客户端软件(或 oracle 数据库),您可以使用tnsping检查您的 TNSNAMES.ora 文件是否配置正确。
The most frequent problems with a TNSNAMES.ora file configuration are using the wrong service name and/or using the wrong host name. You may need to change the "ODB_A" to "ODB_A.WORLD" or vice versa, depending upon the SQLNET settings. For Oracle 10, the latter is the default SQLNET setting. For the latter, you need to use pingto see server "A", and know if you need to use "SERVERA" or "SERVERA.DOMIN.COM" or an IP address.
TNSNAMES.ora 文件配置最常见的问题是使用错误的服务名称和/或使用错误的主机名。根据 SQL NET 设置,您可能需要将“ODB_A”更改为“ODB_A.WORLD”,反之亦然。对于 Oracle 10,后者是默认的 SQLNET 设置。对于后者,您需要使用ping来查看服务器“A”,并知道您是否需要使用“SERVERA”或“SERVERA.DOMIN.COM”或 IP 地址。
回答by Stikut
Had the same problem. Turns out the TNSNAMES.ORA in out deployment environment had a different ADDRESS_NAME and SID/SERVICE_NAME ,and the application was configured to use the SID - which caused the problem.
有同样的问题。结果发现部署环境中的 TNSNAMES.ORA 具有不同的 ADDRESS_NAME 和 SID/SERVICE_NAME ,并且应用程序被配置为使用 SID - 这导致了问题。
Your connection string must contain the ADDRESS_NAME and not the SID
您的连接字符串必须包含 ADDRESS_NAME 而不是 SID
回答by Vivek Vermani
Possible Resolutions -
可能的解决方案 -
Verify that the TNSNAMES.ORA exists and is accessible.
验证 TNSNAMES.ORA 是否存在并且可以访问。
Make sure that there are no syntax errors in TNSNAMES.ORA.
确保 TNSNAMES.ORA 中没有语法错误。
Verify that the connection string is correct.
验证连接字符串是否正确。
Verify if there are any DNS issues.
验证是否存在任何 DNS 问题。
If the problem is while connect to server using PL sql developer client.try to install SQL developer within Program File instead of Program Files(x86)'s
如果问题出在使用 PL sql developer client 连接到服务器时。尝试在 Program File 而不是 Program Files(x86) 中安装 SQL developer
回答by Rohit Hans
Add the environment:
添加环境:
Variable Name: TNS_ADMIN
Variable Value: (YourDrive):\app\(UserName)\product.2.0\dbhome_1\NETWORK\ADMIN
回答by Sarath Avanavu
I had faced the similar issue. The below code was working in my system but was not working in another server even though I had added a tns entry in tnsnames.ora file.
我遇到过类似的问题。下面的代码在我的系统中工作,但在另一台服务器中不起作用,即使我在 tnsnames.ora 文件中添加了一个 tns 条目。
con = new OracleConnection();
con.ConnectionString = "User Id=username;Password=password;Data Source=uit45";
con.Open(); // throws error here
After digging and digging, I found out the solution for this. We need to ignore the entry in tns file and can be given tns entry as connection string, which worked fine for me. Try the below code.
经过挖掘和挖掘,我找到了解决方案。我们需要忽略 tns 文件中的条目,并且可以将 tns 条目作为连接字符串提供,这对我来说很好用。试试下面的代码。
con = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=db-uit45.xxx)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SID=uit45)));User Id=username;Password=password");
con.Open();
Note that you need to give the associated values, especially for HOST,PORT,SID,User Id
and Password
.
请注意,您需要提供关联的值,尤其是HOST,PORT,SID,User Id
和Password
。
回答by dacracot
Is ORACLE_HOME set on server B?
是否在服务器 B 上设置了 ORACLE_HOME?
回答by Moshe
It seems you need to install Oracle Client on "Server B" (the application server), and configure it's TNSNAMES.ORA file. This is required since otherwise, the running code will have no idea where to look for the database you use in the application (probably you're configured a data source in web.config or hard-coded something). Remember - you cannot access Oracle (easily) without Oracle Client.
看来您需要在“服务器 B”(应用程序服务器)上安装 Oracle Client,并配置它的 TNSNAMES.ORA 文件。这是必需的,否则,正在运行的代码将不知道在哪里查找您在应用程序中使用的数据库(可能您在 web.config 中配置了数据源或进行了硬编码)。请记住 - 如果没有 Oracle 客户端,您将无法(轻松)访问 Oracle。