Why do I get ORA-12514 with easy connect but not with TNS?

做~自己de王妃 提交于 2019-12-13 03:36:29

问题


I can connect successfully to my database with a TNS-style connect descriptor:

connect <user>/<pass>@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=<host>)(Port=<port>))(CONNECT_DATA=(SID=<sid>)));

But when I try to connect like this:

connect <user>/<pass>@<host>:<port>/<sid>;

I get ORA-12514: TNS:listener does not currently know of service requested in connect descriptor.

Why does the fist command work but the second does not?


回答1:


SID and service name are not the same thing. In your working version you're explicitly saying you're using the SID, in the CONNECT_DATA part.

When you use the easy connect syntax:

CONNECT username@[//]host[:port][/[service_name][:server]][/instance_name]]
Enter password: password

... you are not supplying the SID; you're actually doing:

connect <user>/<pass>@<host>:<port>/<service_name>

The service name and SID might be the same, but since you're getting that error, in your case they don't seem to be. If you have access to the server you might be able to run lsnrctl services to see which service names are recognised. Or if you can connect as a user with sufficient privileges you can query:

select value from v$parameter where name = 'service_names';

There could be more than one service name reported by either method, and you can probably use any. You may have one like <SID>.<domain> which could be an obvious choice. If in doubt though ask you DBA which you should be using.



来源:https://stackoverflow.com/questions/26057058/why-do-i-get-ora-12514-with-easy-connect-but-not-with-tns

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!