Oracle服务器与客户端的大版本需要一致才能连接成功
配置Oracle Client
下载
先下载与服务器版本对应的Oracle Client,并解压
设置环境变量
1.在Path中添加解压Oracle Client的路径,并放置在第一位
2.添加两个环境变量
变量:NLS_LANG
值:AMERICAN_AMERICA.AL32UTF8
变量:TNS_ADMIN
值:Oracle Client的路径
设置.ora文件
在Oracle Client文件夹下,有sqlnet.ora和tnsnames.ora
sqlnet.ora是一些配置信息,包括如何选择数据库连接字符串,详情见这里
比如
# sqlnet.ora Network Configuration File: E:\Oracleclient12c32x\instantclient_12_1\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)
SQLNET.ALLOWED_LOGON_VERSION=8
tnsnames.ora设置数据库IP、端口号、协议、服务名/SID等信息,可以设置多个连接
比如
# tnsnames.ora Network Configuration File: E:\Oracleclient12c32x\instantclient_12_1\tnsnames.ora
# Generated by Oracle configuration tools.
PDBORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = PDBORCL)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.0)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ORCL33 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
配置PLSQL Developer
PLSQL Developer是一种连接Oracle数据库的工具
下载并安装PLSQL Developer
配置Oracle Client的路径
打开PLSQL Developer,菜单栏选择工具-首选项
在连接设置Oracle主目录和OCI库的路径
Oracle主目录即Oracle Client的路径
OCI库是oci.dll文件的路径,oci.dll在Oracle Client文件夹内
设置如下
参考PLSQL连接Oracle的客户端配置
PLSQL的使用