[oracle]Pro*c链接oracle数据库
一程序链接oracle数据库
EXEC
SQL
CONNECT
:DbUser IDENTIFIED
BY
:DbPasswd USING :DbServer;
其中DbServer为UCRC
查文件未发现一IP地址的定义如何链接的远端数据库?
tnsnamesora 文件的存放路径为 $ORACLE_HOME/network/admin 以下是一个示例
OIDLOCALDOMAIN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhostlocaldomain)(PORT =
))
)
(CONNECT_DATA =
(SERVICE_NAME = oid)
)
)
CAMSLOCALDOMAIN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhostlocaldomain)(PORT =
))
)
(CONNECT_DATA =
(SERVICE_NAME = cams)
)
)
INST_HTTPLOCALDOMAIN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhostlocaldomain)(PORT =
))
)
(CONNECT_DATA =
(SERVER = SHARED)
(SERVICE_NAME = MODOSE)
(divSENTATION =//admin)
)
)
EXTPROC_CONNECTION_DATALOCALDOMAIN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(
KEY
= EXTPROC))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(divSENTATION = RO)
)
)
说明
tnsnamesora 文件中定义一个或多个网络服务 net service cams 实例对应的网络服务为
CAMSLOCALDOMAIN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = localhostlocaldomain)
(PORT = ))
)
(CONNECT_DATA =
(SERVICE_NAME = cams)
)
)
注意 这里 ADDRESS项包含三个子参数
PROTOCOL 默认协议TCP
HOST :ip地址
PORT端口默认
CAMSLOCALDOMAIN为数据名
要确保在监听文件中也有对应的一个 ADDRESS 项也包含同样的三个子参
数 并且子参数的值对应都相等 另外 这里 SERVICE_NAME 的值必需确
保与监听文件中某 SID_DESC项下的 SID_NAME参数的值相等