Linux Oracle SID 和服务名称;连接问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13691628/
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
Oracle SID and Service name; connection problems
提问by user1751356
I'm trying to connect to oracle db on remote server through sql developer. I copied the connection details to tnsnames and I'm able to connect to the db.
我正在尝试通过 sql developer 连接到远程服务器上的 oracle db。我将连接详细信息复制到 tnsnames 并且我能够连接到数据库。
However i have another db application which is same as sqldeveloper and when I try to make a connection, I keep getting this error. This application uses oracle jdbc thin client which requires hostname and SID.
但是,我有另一个与 sqldeveloper 相同的数据库应用程序,当我尝试建立连接时,我不断收到此错误。此应用程序使用需要主机名和 SID 的 oracle jdbc 瘦客户端。
I got the below error:
我收到以下错误:
java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
java.sql.SQLException:侦听器拒绝连接并出现以下错误:ORA-12505,TNS:侦听器当前不知道连接描述符中给出的 SID
While troubleshooting, I changed the tns option in sqldeveloper and I have selected basic option to find out what went wrong and I realized that I'm able to connect to it because of the correct service name and not able to connect to the db via SID name even through sqldeveloper.
在进行故障排除时,我更改了 sqldeveloper 中的 tns 选项,我选择了基本选项来找出问题所在,我意识到我能够连接到它,因为服务名称正确,但无法通过 SID 连接到数据库甚至通过 sqldeveloper 命名。
I have used some db queries to find out SID name but still i keep getting the same error. Please help me troubleshoot.
我使用了一些 db 查询来找出 SID 名称,但我仍然遇到相同的错误。请帮我排除故障。
Thanks for your time..
谢谢你的时间..
采纳答案by A B
ORA-12505 means your client passed a SID that the listener on the server end didn't recognize at all.
ORA-12505 表示您的客户端传递了服务器端的侦听器根本无法识别的 SID。
In 10G and above You can use EZ connect without configuring the server side like this:
在10G及以上你可以使用EZ connect而不用像这样配置服务器端:
sqlplus hr@liverpool:1521/DEMO
hr is the user name
liverpool is the server name
1521 is the port the listener for the DB is listening on
DEMO is the database SID
(OR)
(或者)
If you still want to use tnsnames.ora, try running tnsping SID from your client.
如果您仍想使用 tnsnames.ora,请尝试从您的客户端运行 tnsping SID。
On LINUX, You can also have ORACLE read a tnsnames.ora file from a local path - just set TNS_ADMIN to the directory where your tnsnames.ora file is.
在 LINUX 上,您还可以让 ORACLE 从本地路径读取 tnsnames.ora 文件 - 只需将 TNS_ADMIN 设置为 tnsnames.ora 文件所在的目录。
Otherwise, you need to configure tnsnames.ora in $ORACLE_HOME/network/admin on the client
否则,您需要在客户端的 $ORACLE_HOME/network/admin 中配置 tnsnames.ora
If you need to know the database SID, use this:
如果您需要知道数据库 SID,请使用以下命令:
select sys_context('userenv','db_name') from dual;
select sys_context('userenv','db_name') from dual;
See this URL:
看到这个网址:
回答by ?yvind ?fsthsu
I'm facing this problem too. Linux with oracle 11.2.0.1.
我也面临这个问题。带有 oracle 的 Linux11.2.0.1.
What I found was that the connection string must be:
我发现连接字符串必须是:
sqlplus hr@liverpool:1521:DEMO
and not
并不是
sqlplus hr@liverpool:1521/DEMO