這種問題通常是由於客戶端不知道要連那個instance或者不知道要使用哪一個TNS Alias sql
可能的緣由1.服務沒有起來
下邊是Tom的一個Test Case來講明OracleServiceSID服務沒有起來的話,是會引發ORA-12560錯誤的。
[plain] view plaincopyprint?
C:\Documents and Settings\tkyte>sqlplus scott/tiger
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:43:55 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
scott%ORA10GR1> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
C:\Documents and Settings\tkyte>net stop oracleserviceora10gr1
The OracleServiceORA10GR1 service is stopping.........
The OracleServiceORA10GR1 service was stopped successfully.
C:\Documents and Settings\tkyte>sqlplus scott/tiger
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:44:35 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name:
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name:
ERROR:
ORA-12560: TNS:protocol adapter error
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
C:\Documents and Settings\tkyte>net start oracleserviceora10gr1
The OracleServiceORA10GR1 service is starting..........
The OracleServiceORA10GR1 service was started successfully.
C:\Documents and Settings\tkyte>sqlplus scott/tiger
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:45:12 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
scott%ORA10GR1><A name=PAGETOP></A> 數據庫
C:\Documents and Settings\tkyte>sqlplus scott/tiger oracle
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:43:55 2007 工具
Copyright (c) 1982, 2005, Oracle. All rights reserved. spa
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options .net
scott%ORA10GR1> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options 命令行
C:\Documents and Settings\tkyte>net stop oracleserviceora10gr1
The OracleServiceORA10GR1 service is stopping.........
The OracleServiceORA10GR1 service was stopped successfully. get
C:\Documents and Settings\tkyte>sqlplus scott/tiger cmd
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:44:35 2007 it
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name:
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name:
ERROR:
ORA-12560: TNS:protocol adapter error
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
C:\Documents and Settings\tkyte>net start oracleserviceora10gr1
The OracleServiceORA10GR1 service is starting..........
The OracleServiceORA10GR1 service was started successfully.
C:\Documents and Settings\tkyte>sqlplus scott/tiger
SQL*Plus: Release 10.1.0.4.0 - Production on Thu Sep 6 15:45:12 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
scott%ORA10GR1>修改方法:控制面板>管理工具>服務裏邊把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: