oracle 无法与 SQLPlus 连接,但它适用于 SQL Developer

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

Unable to connect with SQLPlus, but it works with SQL Developer

oraclesqlplus

提问by priceline

Windows 7, Oracle 11.2.0.1; it used to be working fine, not sure what happened lately. But I am not able to connect to SQL plus using sqlplus, and entering user name and password.

Windows 7、Oracle 11.2.0.1;以前还好好的,不知道最近怎么样了。但是我无法使用 sqlplus 并输入用户名和密码连接到 SQL plus。

SQL Developer is working fine. Also the following command is working fine:

SQL Developer 工作正常。此外,以下命令工作正常:

sqlplus system/system@//localhost:1521/ORACUSTOM

Though the above command is working fine, some of the scripts are not working (as these scripts try to connect to a different database. So I need to make the following work:

虽然上面的命令工作正常,但一些脚本不起作用(因为这些脚本尝试连接到不同的数据库。所以我需要做以下工作:

$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 10 19:35:34 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Enter user-name: system
Enter password:
ERROR:
ORA-12560: TNS:protocol adapter error

Enter user-name:

I'd appreciate if you can explain why one approach is working and the other is not.

如果您能解释为什么一种方法有效而另一种方法无效,我将不胜感激。

回答by Sathyajith Bhat

The jdbc connection string

jdbc 连接字符串

sqlplus system/system@//localhost:1521/ORACUSTOM

indicates that the service name 'ORACUSTOM' is used as the service name. Check the tnsnames.ora file for the right TNS name & ensure that it uses 'Oracustom' as the service name

表示使用服务名称“ORACUSTOM”作为服务名称。检查 tnsnames.ora 文件以获取正确的 TNS 名称并确保它使用“Oracustom”作为服务名称

In your case the TNS name should be something like

在您的情况下,TNS 名称应该类似于

orcl =
 (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(Host = localhost)(Port = 1521))
   )
 (CONNECT_DATA =
   (SERVICE_NAME = oracustom)
 )
)

With this entry in tnsnames.ora, you'll have to enter system@orclas the username

使用 tnsnames.ora 中的此条目,您必须输入system@orcl用户名

(PS: Don't login as system. Bad idea.)

(PS:不要以系统身份登录。坏主意。)