ODP .NET TNS:无侦听器
我目前正在尝试连接到 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
实际问题是防火墙。
显然,我的本地开发计算机可以访问托管 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.
我有完全相同的问题。由于某种原因,似乎使用“别名”不起作用。
我的 tnsnames.ora 文件有这样的内容:
然后我将连接字符串的数据源从(使用别名)更改
为(不使用别名):
一切正常现在使用 ODP.NET。当我使用旧的 ADODB 连接时,它过去和现在仍然使用别名。
更新:
ODP.NET 无法直接从您的应用读取您的
tnsnames.ora
文件。您需要像我在回答中所说的那样进行调整,或者您也可以指定tnsnames.ora
文件在Web.Config
或App.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:I then changed my connection string's
Data Source
from (using the alias):To (not using the alias) :
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 yourtnsnames.ora
file is in yourWeb.Config
orApp.Config
file.See my other answer for more details about all options you have.
您的 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.
我还学到了另一件事。
Network\admin 文件夹内的 TNSNAMES.ora 文件在实例开头不能有空格。
例子:
I learned another thing too.
the TNSNAMES.ora file, inside Network\admin folder cannon have spaces at the beginning of the instances.
example: