oracle ODP .NET TNS:没有侦听器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4036785/
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
ODP .NET TNS:no listener
提问by jreddy
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.
我目前正在尝试连接到 Oracle 数据库。我可以在我的开发机器上正常连接,但是当我部署到我的 Win2k3 sp2 服务器时,我收到以下错误。
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)
无法打开连接... Oracle.DataAccess.Client.OracleException ORA-12541: TNS: 在 Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object scr, String程序,布尔 bCheck)
Any thoughts, ideas, instructions would be helpful. I'm using Oracle.DataAccess.dll version 4.112.1.2.
任何想法、想法、指示都会有所帮助。我使用的是 Oracle.DataAccess.dll 版本 4.112.1.2。
Thanks
谢谢
采纳答案by jreddy
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.
显然,我的本地开发机器可以访问托管 Oracle 的服务器,但我的开发服务器却没有。一旦两台服务器之间打开连接,TNS:no listener 错误就会消失。
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.
这似乎是 Oracle 客户端返回的虚假错误消息。监听器在那里,我的配置(连接字符串)是有效的,但是两台机器之间没有可用的连接。
回答by Maxime
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:
我的tnsnames.ora
文件有这样的内容:
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):
然后我更改了我的连接字符串Data Source
(使用别名):
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.NETnow. It was and is still working with the alias when I use an old ADODB connection.
现在一切都可以与ODP.NET完美配合。当我使用旧的 ADODB 连接时,它曾经并且仍在使用别名。
UPDATE:
更新:
ODP.NET cannot read your tnsnames.ora
file directlyfrom 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.
ODP.NET 无法直接从您的应用程序读取您的tnsnames.ora
文件。您需要像我在回答中所说的那样进行调整,或者您也可以指定您的文件在您的或文件中的位置。 tnsnames.ora
Web.Config
App.Config
See my other answerfor more details about all options you have.
有关您拥有的所有选项的更多详细信息,请参阅我的其他答案。
回答by Adam Mendoza
I learned another thing too. the TNSNAMES.ora file, inside Network\admin folder cannon have spaces at the beginning of the instances.
我也学到了另一件事。Network\admin 文件夹中的 TNSNAMES.ora 文件在实例的开头有空格。
example:
例子:
MYORACLESERVER =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = tcp)(HOST = myoracleserver.mydomain.com)(PORT = 1525))
)
(CONNECT_DATA =
(SID = MYORACLESERVER)
)
)
回答by REW
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.
您的 TNSNames 条目指向的机器似乎没有运行侦听器。我可以看到三个不同的选项......(1)该条目指向 tnsnames.ora 中的不同机器(两台机器上不同),(2)这两台机器之间的 DNS 解析不同,或者(3)侦听器是如果机器上正在运行一个端口,则可能会侦听不同的端口。