ODP .NET TNS:无侦听器

发布于 2024-09-29 05:13:31 字数 420 浏览 4 评论 0原文

我目前正在尝试连接到 Oracle 数据库。我可以在我的开发计算机上正常连接,但是当我部署到我的 Win2k3 sp2 服务器时,出现以下错误。

无法打开连接... Oracle.DataAccess.Client.OracleException ORA-12541: TNS: Oracle.DataAccess.Client.OracleException.HandleErrorHelper 处没有liestener(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object scr, String过程,布尔 bCheck)

任何想法、想法、指示都会有帮助。我正在使用 Oracle.DataAccess.dll 版本 4.112.1.2。

谢谢

I'm currently trying to connect to an Oracle database. I can connect fine on my development machine, but when I deploy to my Win2k3 sp2 server I get the following error.

Faile to open connection... Oracle.DataAccess.Client.OracleException ORA-12541: TNS:no liestener at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object scr, String procedure, Boolean bCheck)

Any thoughts, ideas, instructions would be helpful. I'm using Oracle.DataAccess.dll version 4.112.1.2.

Thanks

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

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

发布评论

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

评论(4

看海 2024-10-06 05:13:31

实际问题是防火墙。

显然,我的本地开发计算机可以访问托管 Oracle 的服务器,但我的开发服务器却不能。一旦两个服务器之间建立开放连接,TNS:无侦听器错误就会消失。

这似乎是 Oracle 客户端返回的虚假错误消息。侦听器在那里,我的配置(连接字符串)有效,但两台机器之间没有可用的连接。

The actual issue was a firewall.

Apparently my local development machine had access to the server hosting Oracle, but my development Server did not. Once there was an open connection between the two servers, the TNS:no listener error went away.

This appears to have been a bogus error message returned by the Oracle Client. The listener was there and my configuration (connection string) was valid, but there was no available connection what-so-ever between the two machines.

末骤雨初歇 2024-10-06 05:13:31

我有完全相同的问题。由于某种原因,似乎使用“别名”不起作用。

我的 tnsnames.ora 文件有这样的内容:

oracle =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = tcp)(HOST = myoracleserver.mydomain.com)(PORT = 1525))
    )
    (CONNECT_DATA =
      (SID = MYORACLESERVER)
    )
  )

然后我将连接字符串的数据源从(使用别名)更改

User Id=scott;Password=tiger;Data Source=oracle

为(不使用别名):

User Id=scott;Password=tiger;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=myoracleserver.mydomain.com)(PORT=1525)))CONNECT_DATA = (SID = MYORACLESERVER)))

一切正常现在使用 ODP.NET。当我使用旧的 ADODB 连接时,它过去和现在仍然使用别名。

更新:

ODP.NET 无法直接从您的应用读取您的 tnsnames.ora 文件。您需要像我在回答中所说的那样进行调整,或者您也可以指定 tnsnames.ora 文件在 Web.ConfigApp.Config 文件。

有关您拥有的所有选项的更多详细信息,请参阅我的其他答案

I had the exact same issue. For some reason, it seems that using the "alias" was not working.

My tnsnames.ora file had something like this:

oracle =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = tcp)(HOST = myoracleserver.mydomain.com)(PORT = 1525))
    )
    (CONNECT_DATA =
      (SID = MYORACLESERVER)
    )
  )

I then changed my connection string's Data Source from (using the alias):

User Id=scott;Password=tiger;Data Source=oracle

To (not using the alias) :

User Id=scott;Password=tiger;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=myoracleserver.mydomain.com)(PORT=1525)))CONNECT_DATA = (SID = MYORACLESERVER)))

Everything works flawlessly with ODP.NET now. It was and is still working with the alias when I use an old ADODB connection.

UPDATE:

ODP.NET cannot read your tnsnames.ora file directly from your app. You need to tweak like I said in my answer or you can also specify where your tnsnames.ora file is in your Web.Config or App.Config file.

See my other answer for more details about all options you have.

玻璃人 2024-10-06 05:13:31

您的 TNSNames 条目指向的计算机似乎没有运行侦听器。我可以看到三个不同的选项...(1)条目指向 tnsnames.ora 中的不同机器(两台机器上不同),(2)这两台机器之间的 DNS 解析不同,或者(3)侦听器是如果机器上正在运行一个端口,则可能会监听不同的端口。

It would appear that the machine your TNSNames entry is pointing at does not have a listener running. Three different options I could see... (1) the entry is pointing a different machines in tnsnames.ora (different on both machines), (2) the DNS resolution is different between these two machines, or (3) the listener is listening on a different port possibly if there is one running on the machine.

硪扪都還晓 2024-10-06 05:13:31

我还学到了另一件事。
Network\admin 文件夹内的 TNSNAMES.ora 文件在实例开头不能有空格。

例子:

MYORACLESERVER =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = tcp)(HOST = myoracleserver.mydomain.com)(PORT = 1525))
    )
    (CONNECT_DATA =
      (SID = MYORACLESERVER)
    )
  )

I learned another thing too.
the TNSNAMES.ora file, inside Network\admin folder cannon have spaces at the beginning of the instances.

example:

MYORACLESERVER =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = tcp)(HOST = myoracleserver.mydomain.com)(PORT = 1525))
    )
    (CONNECT_DATA =
      (SID = MYORACLESERVER)
    )
  )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文