oracle ORA-12545: 连接失败,因为目标主机或对象不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4800958/
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-12545: Connect failed because target host or object does not exist
提问by eece
Have anyone encounter this error before? I tried to refer to this link: http://www.ardentperf.com/2007/04/02/local_listener-and-ora-12545/
有没有人遇到过这个错误?我试着参考这个链接:http: //www.ardentperf.com/2007/04/02/local_listener-and-ora-12545/
But it doesn't really resolve our issue. Our scenario is that we are able to connect to the database however we will encounter this error when we try to select data from a view.
但它并没有真正解决我们的问题。我们的场景是我们能够连接到数据库,但是当我们尝试从视图中选择数据时会遇到此错误。
I have enabled Client-side sqlnet trace but i am unable to interpret what is the exact cause of the issue.
我已启用客户端 sqlnet 跟踪,但我无法解释问题的确切原因。
Any ideas anyone?
任何人的想法?
Thanks
谢谢
回答by Jeremy Thompson
For me the problem was the HOST was not being detected by name in the TNSNAMES.ora, using the IP address instead resolved it (I think its due to a domain controller issue):
对我来说,问题是在 TNSNAMES.ora 中没有通过名称检测到主机,而是使用 IP 地址解决了它(我认为这是由于域控制器问题):
XYZD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.45.67.89)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = XYZD))
)
Do a command: “ping HOST” to find the servers IP address.
执行命令:“ping HOST”以查找服务器 IP 地址。
- PING HOST
- TELNET HOST PORT
- TNSPING TNS_ALIAS
- Ping 主机
- 远程登录主机端口
- TNSPING TNS_ALIAS
Edit:
编辑:
Just ran into this again, this time it was a Firewall blocking TCP via the port.
刚刚再次遇到这个问题,这次是防火墙通过端口阻止了 TCP。
回答by Roberto Navarro
This issue can be multiple things:
这个问题可以是多方面的:
1. Your TNSNAMES.ora isn't up to date
1. 您的 TNSNAMES.ora 不是最新的
Fix: Find your Oracle Home Find Directory: /network/ADMIN/
修复:找到您的 Oracle Home Find Directory:/network/ADMIN/
TNSNAMES.ora should be in there if you're experiencing this issue on a local machine
如果您在本地计算机上遇到此问题,则 TNSNAMES.ora 应该在那里
2. Create TNS_ADMIN Environmental Variable
2. 创建 TNS_ADMIN 环境变量
In my case:
就我而言:
Variable Name: TNS_ADMIN
变量名称:TNS_ADMIN
Value: C:\Programs\Ora10g\network\ADMIN
值:C:\Programs\Ora10g\network\ADMIN
For testing purposes, try connecting to the Oracle DB using sqlplus (you may already be trying this).
出于测试目的,请尝试使用 sqlplus 连接到 Oracle DB(您可能已经在尝试此操作)。
回答by Ashwin A.Vardhan
I also had this issue, and since I was not using a tnsnames.ora file, I almost gave up hope, when I stepped on this link.
So, now my code looks like this:
我也有这个问题,因为我没有使用 tnsnames.ora 文件,所以当我踩到这个链接时,我几乎放弃了希望。
所以,现在我的代码是这样的:
import cx_Oracle
connection_string = '''username/password@(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=<host_name>)
(PORT=<port_numer>)
)
)
(CONNECT_DATA=
(SID=<your_SID>)
)
)'''
db = cx_Oracle.connect(connection_String)
Now you can create a cursor and write your query.
Note: This is not a recommended practice, but I used it just for testing.
现在您可以创建一个游标并编写您的查询。
注意:这不是推荐的做法,但我仅将其用于测试。