赞
踩
由于课程项目需要,要远程连接数据库,弄了两天,终于搞定,写一下心路历程。
用 Sql Developer 和 Java代码两个同时测试,出现了好几个问题
ora-12541:TNS:无监听程序
ora 12514 tns listener does not currently know of service requested in connect descriptor
oracle数据库无法连接 The Network Adapter could not establish
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
反正就很烦,这几个问题来回出现
Google上搜,最终修改了2个代码文件,他们的位置都在
E:\app\Oracle\product\12.1.0\dbhome_1\NETWORK\ADMIN 这个目录下
修改后的2个文件如下:
listener.ora
# listener.ora Network Configuration File: E:\app\Oracle\product\12.1.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\Oracle\product\12.1.0\dbhome_1)
# (PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:E:\app\Oracle\product\12.1.0\dbhome_1\bin\oraclr12.dll")
)
###########################################################
(SID_DESC =
(SID_NAME = orcl)
(ORACLE_HOME = E:\app\Oracle\product\12.1.0\dbhome_1)
# (PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:E:\app\Oracle\product\12.1.0\dbhome_1\bin\oraclr12.dll")
)
)
############################################################
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.60.36.91)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
注意两行“#” 之间的代码为新添加,为了解决上述问题4
还有Listener中的Host记得改
tnsnames.ora
# tnsnames.ora Network Configuration File: E:\app\Oracle\product\12.1.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
# ORCL =
# (DESCRIPTION =
# (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
# (CONNECT_DATA =
# (SERVER = DEDICATED)
# (SERVICE_NAME = orcl.microdone.cn)
# )
# )
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.60.36.91)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.microdone.cn)
)
)
被“#”注释掉的几行代码是原本的支持本地连接的代码,下面的一段是重新改过的。
中间用了
tnsping 10.60.36.91:1521/orcl
这个命令测试了下是不是能连上,然后发现了问题一
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。