PL/SQL连接Oracle数据库的时候 报"ORA-12514: TNS:监听程序当前无法识别连接描述符中请求的服务" 错误;
参考了很多别人的处理方案,配置了好久,最终莫名其妙成功了,大致的关键步骤如下:
1、在Oracle安装目录 NetWork中 找到listener.ora文件,编辑:
(根据自己情况查找) 修改,添加内容:
#listener.ora Network Configuration File: #e:\app\Administrator\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 = e:\app\Administrator\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = “EXTPROC_DLLS=ONLY:e:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll”)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(SID_NAME = orcl)
)
(SID_DESC=
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = E:\app\Administrator\product\11.2.0\dbhome_1)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.1)(PORT = 1521))
)
)
ADR_BASE_LISTENER = e:\app\Administrator
2、在Oracle安装目录 NetWork中 找到 tnsnames.ora,编辑此文件:
修改自己的数据库MyOracleDB的连接配置:
MyOracleDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
注意:host默认为localhost,如果失败,再改成本机ip地址。
两个文件保存后,重启服务,PL/SQL连接数据库报另一个错 ORA-12523: TNS:监听程序无法找到适用于客户机连接的例程;
最后这里有一个关键的步骤,要这样处理
3、现将Oracle所有的服务都停掉,然后按照顺序启动服务,先启动监听程序,再启动数据库服务,然后再试数据库一切正常。