ORA-12560: TNS:protocol adapter error(TNS:协议适配器错误)

这种问题一般是因为客户端不知道要连那个instance或者不知道要使用哪个TNS Alias

可能的原因1.服务没有起来
下边是Tom的一个Test Case来说明OracleServiceSID服务没有起来的话,是会引起ORA-12560错误的。
  1. C:\Documents and Settings\tkyte>sqlplus scott/tiger  
  2.   
  3. SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:43:55 2007  
  4.   
  5. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  6.   
  7.   
  8. Connected to:  
  9. Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production  
  10. With the Partitioning, OLAP and Data Mining options  
  11.   
  12. scott%ORA10GR1> exit  
  13. Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production  
  14. With the Partitioning, OLAP and Data Mining options  
  15.   
  16. C:\Documents and Settings\tkyte>net stop oracleserviceora10gr1  
  17. The OracleServiceORA10GR1 service is stopping.........  
  18. The OracleServiceORA10GR1 service was stopped successfully.  
  19.   
  20.   
  21. C:\Documents and Settings\tkyte>sqlplus scott/tiger  
  22.   
  23. SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:44:35 2007  
  24.   
  25. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  26.   
  27. ERROR:  
  28. ORA-12560: TNS:protocol adapter error  
  29.   
  30.   
  31. Enter user-name:  
  32. ERROR:  
  33. ORA-12560: TNS:protocol adapter error  
  34.   
  35.   
  36. Enter user-name:  
  37. ERROR:  
  38. ORA-12560: TNS:protocol adapter error  
  39.   
  40.   
  41. SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus  
  42.   
  43. C:\Documents and Settings\tkyte>net start oracleserviceora10gr1  
  44. The OracleServiceORA10GR1 service is starting..........  
  45. The OracleServiceORA10GR1 service was started successfully.  
  46.   
  47.   
  48. C:\Documents and Settings\tkyte>sqlplus scott/tiger  
  49.   
  50. SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:45:12 2007  
  51.   
  52. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  53.   
  54.   
  55. Connected to:  
  56. Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production  
  57. With the Partitioning, OLAP and Data Mining options  
  58.   
  59. scott%ORA10GR1><a name="PAGETOP"></a>  
修改方法:控制面板>管理工具>服务里边把OracleServiceSID起起来

 
可能的原因2.ORACLE_SID环境变量没有指定(最常见引起ORA-12560问题的原因)
检查方法,命令行(cmd)下,
C:\Documents and Settings\ptian>set oracle_sid
ORACLE_SID=test
ORACLE_SID是sqlplus默认连接的数据库instance,即sqlplus user/pwd连接的instance,如果不指定sqlplus里连接的时候就需要明确@你的instance,eg,sqlplus user/pwd@instance.
修改方法:在注册表中,HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraDb10g_home1\ORACLE_SID 需指向你的Instance(eg.orcl);或者在系统的环境变量里加ORACLE_SID项,值为Instance的SID。

可能的原因3.TNS_ADMIN环境变量没有指定
检查方法,命令行(cmd)下,
C:\Documents and Settings\ptian>set TNS_ADMIN
TNS_ADMIN=D:\oracle\product\10.1.0\Db_1\NETWORK\ADMIN
TNS_ADMIN应该返回你的tnsnames.ora所在的目录
修改方法:可以在注册表HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0\TNS_ADMIN或者环境变量中指定。

可能的原因4.ORACLE_HOME环境变量没有指定
和上边的方法类似,检查Oracle_Home环境变量

可能的原因5.tnsnames.ora文件内容不对
A sample:
TEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ptian-cn.cn.oracle.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test)
    )
  )

Possible fixes for the TNS-12560 include:


转自:http://blog.csdn.net/pan_tian/article/details/7699469


PS:关于TNS_ADMIN环境变量

很多oracle产品都有自己的TNS文件,如果你的系统里装了多个Oracle的产品的话,那么客户端连instance的时候,到底是使用那个tnsnames.ora呢?这个时候就需要看TNS_ADMIN这个参数了。


查看方法:命令行
C:\Documents and Settings\ptian>set TNS_ADMIN
TNS_ADMIN=D:\oracle\product\10.1.0\Db_1\NETWORK\ADMIN
这就表示客户端会从D:\oracle\product\10.1.0\Db_1\NETWORK\ADMIN下读取TNS的设置

修改方法:
有两个地方可以修改,一个是注册表,一个是系统环境变量。
注册表的位置:HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0\TNS_ADMIN
系统环境变量的优先级高于注册表,如果设置了环境变量,那么就会忽略注册表的值。

 tns_admin--用于指示tnsnames.ora文件的所在目录

在 HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/KEY_OraDb11g_home1 下
添加键:tns_admin 字符型的键 ,对应的键值为h:/

注意:此键值用于指示tnsnames.ora的所在目录。所以,不要写成h:/tnsnames.ora的形式




  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值