Oracle问题之ORA-12560TNS:协议适配器错误-转载
作者:@haimishasha
本文为作者原创,转载请注明出处:https://www.cnblogs.com/haimishasha/p/5394963.html
目录
Oracle问题之ORA-12560TNS:协议适配器错误
一、造成ORA-12560: TNS: 协议适配器错误的问题的原因有三个:
1.监听服务没有起起来。windows平台个一如下操作:开始---程序---管理工具---服务,打开服务面板,
启动OracleOraDb11g_home1TNSlistener服务。
2.database instance没有起起来。windows平台如下操作:开始---程序---管理工具---服务,打开服务
面板,启动OracleServiceBOOKSALES, BOOKSALES就是你的database SID
3.注册表问题。regedit,然后进入HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME
将该环境变量ORACLE_SID设置为XXXX, XXXX就是你的database SID.
或者右击我的电脑,属性--高级--环境变量---系统变量--新建,变量名=oracle_sid,变量值=XXXX, XXXX就是你的database SID.
或者进入sqlplus前,在command line下输 set oracle_sid=XXXX, XXXX就是你的database SID.
经过以上步骤,一般就可以解决问题。
二、如果还没有解决的话则会遇到以下问题:
1、执行请求的操作时遇到错误:
IO 错误: The Network Adapter could not establish the connection
供应商代码 17002
2、执行请求的操作时遇到错误:
Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
供应商代码 12514
三、解决方法如下:
假如只有一个数据库的话:
1、找到如下路径:
D:\install\oracle\oracle-install\product\11.2.0\dbhome_1\NETWORK\ADMIN
2、将文件中的内容修改如下,当然要结合自己的实际情况做简单修改:
//listener.ora
# listener.ora Network Configuration File: D:\install\oracle\oracle-install\product\11.2.0\dbhome_1\network\admin\listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = D:\install\oracle\oracle-install\product\11.2.0\dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:D:\install\oracle\oracle-install\product\11.2.0\dbhome_1\bin\oraclr11.dll") ) (SID_DESC = (SID_NAME = BOOKSALES) (ORACLE_HOME = D:\install\oracle\oracle-install\product\11.2.0\dbhome_1) (GLOBAL_DBNAME = BOOKSALES) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = acer)(PORT = 1521)) ) ) ADR_BASE_LISTENER = D:\install\oracle\oracle-install
//sqlnet.ora
# sqlnet.ora Network Configuration File: D:\install\oracle\oracle-install\product\11.2.0\dbhome_1\network\admin\sqlnet.ora # Generated by Oracle configuration tools. # This file is actually generated by netca. But if customers choose to # install "Software Only", this file wont exist and without the native # authentication, they will not be able to connect to the database on NT. SQLNET.AUTHENTICATION_SERVICES= (NTS) NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
//tnsnames.ora
# tnsnames.ora Network Configuration File: D:\install\oracle\oracle-install\product\11.2.0\dbhome_1\network\admin\tnsnames.ora # Generated by Oracle configuration tools. BOOKSALES = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = BOOKSALES) ) )
3、重新启动 tnslistener
4、测试的时候要注意修改对应数据库的用户名和密码
Oracle SQL Developer连接的时候也要注意用对应的用户名和密码
执行请求的操作时遇到错误:
IO 错误: The Network Adapter could not establish the connection
供应商代码 17002
执行请求的操作时遇到错误:
Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
供应商代码 12514
也是按照上面修改配置文件