oracle 连接Oracle数据库时遇到java.sql.SQLException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1087111/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 18:32:16  来源:igfitidea点击:

java.sql.SQLException encountered when connecting to Oracle database

javaoraclejdbc

提问by Adam Paynter

I get the following error when I try to run my project:

当我尝试运行我的项目时出现以下错误:

java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169870080)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))) 

Any ideas?

有任何想法吗?

回答by Adam Paynter

You're getting an ORA-12505 error("TNS: listener could not resolve SID given in connection description."). This happens when the SID (System ID) of the database you wish to connect to isn't registered with Oracle's listener. If you can find the JDBC connection information, you may find something that matches this pattern:

您收到ORA-12505 错误(“TNS:侦听器无法解析连接描述中给出的 SID。”)。这种情况发生在SID(小号ystem ID数据库)要连接到没有与Oracle的listener注册。如果您可以找到 JDBC 连接信息,您可能会找到与此模式匹配的内容:

jdbc:oracle:thin:[user]/[password]@[host]:[port]:[sid]

In this case, Oracle is telling you that [sid]does not exist on the server [host]. You may be connecting to the wrong server.

在这种情况下,Oracle 会告诉您[sid]服务器上不存在[host]。您可能连接到错误的服务器。

回答by Mark Rushakoff

Connection refused means that the server is not allowing your client to connect. Double check the server settings and make sure your host is allowed to connect, at the very least.

连接被拒绝意味着服务器不允许您的客户端连接。仔细检查服务器设置并确保您的主机至少可以连接。