Oracle (0x80004005)ORA-12154: TNS: 无法解析连接标识符

发布于 2024-09-14 13:35:33 字数 1348 浏览 3 评论 0原文

我正在尝试从 ASP 经典应用程序连接到 Oracle 数据库,但是我不断遇到 ORA-12154 错误。

  1. TNSNAMES.ORA 配置正确

    DBSOURCE.ABcom = (描述= (地址列表= (地址 = (协议 = TCP)(主机 = CDBcom)(端口 = 1231)) ) (连接数据= (服务名称 = DBSOURCE) ) )

  2. 我可以 TNSPING

    C:\Documents and Settings\USERID.A>tnsping DBSOURCE

    适用于 32 位 Windows 的 TNS Ping 实用程序:版本 10.2.0.4.0 - 于 2 年 3 月 9 日生产 011 09:12:31

    版权所有 (c) 1997、2007,Oracle。保留所有权利。

    使用的参数文件: C:\oracle\product\10.2.0\client_1\NETWORK\ADMIN\sqlnet.ora

    使用TNSNAMES适配器来解析别名 正在尝试联系 (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (主机 = CDBcom)(端口 = 1231))) (CONNECT_DATA = (服务 E_NAME = DBSOURCE))) 好的(30 毫秒)

  3. 我可以创建 ODBC 连接,并且我已经测试了该连接,该连接是成功的。

  4. 我可以通过toad连接到oracle数据库。
  5. 我检查了我的 sqlnet.ora 文件

    NAMES.DEFAULT_DOMAIN = ABcom

    SQLNET.AUTHENTICATION_SERVICES=(无)

    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

  6. I我还检查了 TNSNAMES.ORA 是否为我的系统路径之一。

  7. 我可以使用 SQLPLUS 连接到数据库

这是抛出错误的代码

dim CnnStr

Set Cnn = Server.CreateObject("ADODB.Connection")

CnnStr="Provider=MSDAORA.1;Password=pass;User ID=user;Data Source=DBSOURCE"

Cnn.Open CnnStr

我正在运行 Windows XP Pro 32 位 SP3

我已经在同事的计算机上测试了它并且 asp 应用程序没有问题,我是否在某处缺少配置或者我是否搞乱了我的配置?

感谢大家的帮助!

I'm trying to connect to an oracle db from an ASP classic application, however I keep running into the ORA-12154 error.

  1. TNSNAMES.ORA is configured properly

    DBSOURCE.A.B.com =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = C.D.B.com)(PORT = 1231))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = DBSOURCE)
    )
    )

  2. I can TNSPING

    C:\Documents and Settings\USERID.A>tnsping DBSOURCE

    TNS Ping Utility for 32-bit Windows: Version 10.2.0.4.0 - Production on 09-MAR-2
    011 09:12:31

    Copyright (c) 1997, 2007, Oracle. All rights reserved.

    Used parameter files:
    C:\oracle\product\10.2.0\client_1\NETWORK\ADMIN\sqlnet.ora

    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
    (HOST = C.D.B.com)(PORT = 1231))) (CONNECT_DATA = (SERVIC
    E_NAME = DBSOURCE)))
    OK (30 msec)

  3. I can create an ODBC connection and I've tested the connection which is successful.

  4. I can connect to the oracle db through toad.
  5. I've checked my sqlnet.ora file

    NAMES.DEFAULT_DOMAIN = A.B.com

    SQLNET.AUTHENTICATION_SERVICES= (NONE)

    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

  6. I've also checked that the TNSNAMES.ORA as one of my system paths.

  7. I can connect to the DB with SQLPLUS

Here is the code that throws the error

dim CnnStr

Set Cnn = Server.CreateObject("ADODB.Connection")

CnnStr="Provider=MSDAORA.1;Password=pass;User ID=user;Data Source=DBSOURCE"

Cnn.Open CnnStr

I am running windows XP Pro 32bit SP3

I've tested this on a co-workers machine and the asp app has no issues, am I missing a configuration somewhere or did I mess up my config?

Thanks for the help everyone!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

简单气质女生网名 2024-09-21 13:35:33

似乎所有设置都已检查过,但以下是我对一些故障排除的建议:对

  • 运行 IIS 的帐户的限制怎么样?它是否具有读取 TNSNAMES 的文件权限?您是否尝试过给予用户更多的权利?甚至使用本地系统帐户运行 IIS?记得把它放回原来的样子。
  • 您确定没有第三方应用程序(例如防病毒或防火墙)可能影响/阻止访问。 (禁用它们进行测试,但不要忘记重新启用:)

(你最后做了什么来解决这个问题?)

It seems all the settings have been checked but here is my suggestions for some trouble shooting:

  • How about restrictions on the account IIS is running under? Does it have the file permissions to read the TNSNAMES? Have you tried to give the user more rights. Even run IIS with Local As System Account? Remember to put it back the way it was.
  • You are sure there is not 3rd party app such anti virus or firewall that could influence / block access. (Disable them to test but do not forget to re-enable :)

(What did you finally do to solve it?)

信仰 2024-09-21 13:35:33

“这可以在同事机器上运行,但是
不是我的。”

ORA-12154 通常是一个配置问题,在您的情况下肯定是这样。简短的答案是将您的计算机与您同事的计算机进行比较,找出差异所在。

要检查的事项包括:

  • TNANAMES.ORA 文件
  • SQLNET.ORA 文件
  • LISTENER.ORA 文件(如果您使用的是本地数据库)

"this works on a co-worker machine but
not mine."

ORA-12154 is usually a configuration issue, and it would certainly seem to be so in your case. The short answer is to compare your machine with your colleague's one and figure out what the difference is.

Things to check include:

  • the TNANAMES.ORA file
  • the SQLNET.ORA file
  • the LISTENER.ORA file (if you're using a local database)
童话 2024-09-21 13:35:33

您有多个 Oracle 主目录吗?检查 IIS 是否未指向其他 ORA_HOME(因此未找到您的 tnsnames.ora 条目)。
我对 IIS 配置不是很熟悉,因此我将通过将 TNS 条目添加到我的 PC 上的所有 tnsnames.ora 来测试这一点。

Do you have multiple Oracle homes? Check that IIS doesn't point to the other ORA_HOME (and thereby not finding your tnsnames.ora entry).
I'm not very familiar with IIS configuration, so I would test this by adding the TNS entry to all tnsnames.ora on my PC.

剩一世无双 2024-09-21 13:35:33

如果您运行的是 64 位操作系统和 Oracle 10,请尝试安装 Oracle 的所有补丁。
类似的事情也发生在我身上,除了我的 .NET 程序之外,SQL plus 和其他所有东西都有效。
我正在“Program files (x86)”文件夹中运行 .Net 程序。安装补丁修复了它。

If you are running a 64-bit OS and oracle 10 try installing all the patches for oracle.
Something similar happened to me, SQL plus and all else worked, except my .NET program.
I was running a .Net program out of the "Program files (x86)" folder. Installing patches fixed it.

清引 2024-09-21 13:35:33

可能的问题是 IIS 运行用户缺乏对 Oracle 目录的读取权限。

正如 @Derick 所说,暂时在 $ORACLE_HOME 目录上设置完全开放的权限(每个人 = 完全控制),重新启动 IIS,然后进行测试。当该方法有效时,请授予 IIS 用户对该目录的读取权限。

您还可以使用来自 Microsoft SysInternals 的进程监视器来确认此问题,并查看失败情况在 CreateFile(...) API 调用期间打开 DLL 或读取 TNSNAMES.ORA 文件时显示消息。鉴于通过游标进行选择时临时文件的工作方式,您可能还需要授予 IIS 用户对某些目录的写入权限。

The likely problem is the lack of read permission upon the Oracle directories by the User IIS is running-as.

As @Derick says, temporarily set the permissions wide-open on the $ORACLE_HOME directory (Everyone = Full Control), restart IIS, and test. When that works, give the IIS User read permission against that directory.

You can also confirm this issue using Process Monitor from Microsoft SysInternals, and seeing the failure message during the CreateFile(...) API call to open the DLLs or read the TNSNAMES.ORA file. Given the way temporary files work when selecting through cursors, you may also need to give the IIS user write permissions into some directories.

姐不稀罕 2024-09-21 13:35:33

尝试将有问题的计算机上的环境变量 TNS_ADMIN 的值设置为 /network/admin (或 tnsnames.ora 文件所在的位置),看看是否有帮助。

Try setting the value of the environment variable TNS_ADMIN on the machine with the problem to /network/admin (or wherever your tnsnames.ora file lives) and see if that helps.

茶花眉 2024-09-21 13:35:33

我遇到了类似的问题并找到了一个简单的解决方案。您不必修改任何配置文件。希望这可以帮助您:

CREATE DATABASE LINK server2_db
  CONNECT TO dbuser IDENTIFIED BY pwd USING
 '(DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = server_2)(PORT = port_num))
   )
   (CONNECT_DATA =
     (SERVICE_NAME = server2_db)
   )
 )';

解决方案来自这里:http://oraclequirks.blogspot.com/2008/11/ora-12154-tnscould-not-resolve-service.html

I had the similar problem and found a simple solution. You don't have to modify any config files. Hope this can help you:

CREATE DATABASE LINK server2_db
  CONNECT TO dbuser IDENTIFIED BY pwd USING
 '(DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = server_2)(PORT = port_num))
   )
   (CONNECT_DATA =
     (SERVICE_NAME = server2_db)
   )
 )';

The solution is from here:http://oraclequirks.blogspot.com/2008/11/ora-12154-tnscould-not-resolve-service.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文