PL/SQL連接Oracle數據庫的時候 報"ORA-12514: TNS:監聽程序當前無法識別連接描述符中請求的服務" 錯誤
本例原因:
安裝Oracle時一般默認實例都是orcl,發現有人不按套路出牌,改了名字,如圖
解決方法:
在Oracle安裝目錄 找到listener.ora文件 路徑為 D:\oracle\product\11.2.0\dbhome_1\NETWORK\ADMIN
(根據自己情況查找) 修改:
# listener.ora Network Configuration File: D:\oracl\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:\oracle\product\11.2.0\dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:D:\oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll") ) (SID_DESC = (GLOBAL_DBNAME = JTW) (ORACLE_HOME = D:\oracle\product\11.2.0\dbhome_1) (SID_NAME = JTW) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ) )
紅色部分為新添加內容,JTW為監聽的實例名
然後修改(添加)instantclient_11_2\network\admin\tnsnames.ora
MyOracle = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = jtw) ) )
重啟Oracle監聽