今天公司向客户申请oracle数据库,对方给我们四个ip,通过了解要使用TNS的方式进行连接。特此记录一下链接方式。
通过Navicat连接
- 需要创建tnsnames.ora文件,内容如下
ORACLE_RAC =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xx.xx.xx.xx)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = xx.xx.xx.xx)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = xx.xx.xx.xx)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = xx.xx.xx.xx)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
- 添加到指定目录
Navicat安装目录
C:\Program Files (x86)\PremiumSoft\Navicat Premium 15\instantclient_11_2\network\admin
- 连接oracle数据库
选择 tnsnames.ora 中编写的 ORACLE_RAC
SpringBoot datasource连接字符串
内容如下,为了便于修改,我手动后换行了,修改好对应的ip地址需要将换行符去掉即可
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(
ADDRESS=(PROTOCOL=TCP)(HOST=xx.xx.xx.xx)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=xx.xx.xx.xx)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=xx.xx.xx.xx)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=xx.xx.xx.xx)(PORT=1521))
)(CONNECT_DATA=(SERVICE_NAME=orcl)))
评论区