为什么我可以通过轻松连接获得ORA-12514,而不能通过TNS获得它? [英] Why do I get ORA-12514 with easy connect but not with TNS?

查看:72
本文介绍了为什么我可以通过轻松连接获得ORA-12514,而不能通过TNS获得它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用TNS样式的连接描述符成功连接到数据库:

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>;

我得到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?

推荐答案

SID和服务名称不是同一回事.在工作版本中,CONNECT_DATA部分中明确表示正在使用SID.

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.

使用轻松连接语法:

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

...您不提供SID;您实际上正在做:

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

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

服务名称和SID 可能相同,但是由于您遇到该错误,因此在您看来情况似乎并非如此.如果您有权访问服务器,则可以运行lsnrctl services以查看可识别的服务名称.或者,如果您可以以具有足够特权的用户身份连接,则可以查询:

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';

任何一种方法都可能报告多个服务名称,您可能可以使用任何一个.您可能有一个类似<SID>.<domain>的选项,这可能是显而易见的选择.如有疑问,请问您应该使用哪个DBA.

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.

这篇关于为什么我可以通过轻松连接获得ORA-12514,而不能通过TNS获得它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆