plsql+Oracle客户端连接本地Oracle和远程Oracle的方法
本地Oralce 客户端.ora文件配置容如下
tnsnames.ora
# tnsnames.ora Network Configuration File: D:\app\jkxt\product\11.2.0\client_1\network\admin\tnsnames.ora # Generated by Oracle configuration tools. JKXTORCL205 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.199.102.205)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = JKXTORCL) ) ) ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) ) JKXTORCL21 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.199.102.21)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = JKXTORCL) ) )
ORCL 为本地的oracle 数据库。
JKXTORCL205、JKXTORCL21为远程的Oracle数据库。
listener.ora 监听器配置文件
# listener.ora Network Configuration File: D:\app\jkxt\product\11.2.0\client_1\network\admin\listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) ADR_BASE_LISTENER = D:\app\jkxt
sqlnet.ora
# sqlnet.ora Network Configuration File: D:\app\jkxt\product\11.2.0\client_1\network\admin\sqlnet.ora # Generated by Oracle configuration tools. # This file is actually generated by netca. But if customers choose to # install "Software Only", this file wont exist and without the native # authentication, they will not be able to connect to the database on NT. SQLNET.AUTHENTICATION_SERVICES= (NTS) NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
本地oracle数据库lister.ora设置:
listener.ora
# listener.ora Network Configuration File: d:\app\kll\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:\app\kll\product\11.2.0\dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:d:\app\kll\product\11.2.0\dbhome_1\bin\oraclr11.dll") ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ) ) ADR_BASE_LISTENER = d:\app\kll
sqlnet.ora
# sqlnet.ora Network Configuration File: D:\Oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora # Generated by Oracle configuration tools. # This file is actually generated by netca. But if customers choose to # install "Software Only", this file wont exist and without the native # authentication, they will not be able to connect to the database on NT. SQLNET.AUTHENTICATION_SERVICES= (NTS) NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
tnsnames.ora
# tnsnames.ora Network Configuration File: d:\app\kll\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora # Generated by Oracle configuration tools. ORACLR_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (CONNECT_DATA = (SID = CLRExtProc) (PRESENTATION = RO) ) ) LISTENER_ORCL = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
本地Oracle数据库的tnsnames.ora配置文件还有不明朗之处,应该是不用配置就可以访问远程的、本地的数据库。
其中上文中绿色代码不知道是不是必须的。红色代码为必须,否者远程Oracle数据库会报ORA-12154错误。