Oracle问题之ORA-12560TNS:协议适配器错误
一、造成ORA-12560: TNS: 协议适配器错误的问题的原因有三个:
1.监听服务没有起起来。windows平台个一如下操作:开始---程序---管理工具---服务,打开服务面板,
启动OracleOraDb11g_home1TNSlistener服务。
2.database instance没有起起来。windows平台如下操作:开始---程序---管理工具---服务,打开服务
面板,启动OracleServiceBOOKSALES, BOOKSALES就是你的database SID
3.注册表问题。regedit,然后进入HKEY_LOCAL_MACHINESOFTWAREORACLEHOME
将该环境变量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:installoracleoracle-installproduct11.2.0dbhome_1NETWORKADMIN
2、将文件中的内容修改如下,当然要结合自己的实际情况做简单修改:
//listener.ora
1 # listener.ora Network Configuration File: D:installoracleoracle-installproduct11.2.0dbhome_1 etworkadminlistener.ora 2 # Generated by Oracle configuration tools. 3 4 SID_LIST_LISTENER = 5 (SID_LIST = 6 (SID_DESC = 7 (SID_NAME = CLRExtProc) 8 (ORACLE_HOME = D:installoracleoracle-installproduct11.2.0dbhome_1) 9 (PROGRAM = extproc) 10 (ENVS = "EXTPROC_DLLS=ONLY:D:installoracleoracle-installproduct11.2.0dbhome_1inoraclr11.dll") 11 ) 12 (SID_DESC = 13 (SID_NAME = BOOKSALES) 14 (ORACLE_HOME = D:installoracleoracle-installproduct11.2.0dbhome_1) 15 (GLOBAL_DBNAME = BOOKSALES) 16 ) 17 ) 18 19 LISTENER = 20 (DESCRIPTION_LIST = 21 (DESCRIPTION = 22 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) 23 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521)) 24 (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) 25 (ADDRESS = (PROTOCOL = TCP)(HOST = acer)(PORT = 1521)) 26 ) 27 ) 28 29 ADR_BASE_LISTENER = D:installoracleoracle-install
//sqlnet.ora
1 # sqlnet.ora Network Configuration File: D:installoracleoracle-installproduct11.2.0dbhome_1 etworkadminsqlnet.ora 2 # Generated by Oracle configuration tools. 3 4 # This file is actually generated by netca. But if customers choose to 5 # install "Software Only", this file wont exist and without the native 6 # authentication, they will not be able to connect to the database on NT. 7 8 SQLNET.AUTHENTICATION_SERVICES= (NTS) 9 10 NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
//tnsnames.ora
1 # tnsnames.ora Network Configuration File: D:installoracleoracle-installproduct11.2.0dbhome_1 etworkadmin nsnames.ora 2 # Generated by Oracle configuration tools. 3 4 BOOKSALES = 5 (DESCRIPTION = 6 (ADDRESS_LIST = 7 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521)) 8 ) 9 (CONNECT_DATA = 10 (SERVICE_NAME = BOOKSALES) 11 ) 12 )
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
也是按照上面修改配置文件