【转载】Oracle 12c JDBC方式连接PDB数据库
2020-08-27 09:10 dba+ 阅读(1249) 评论(0) 编辑 收藏 举报1.配置监听
这里假定CDB数据库名为ORCL,PDB在CDB下面名称为PDBORCL
listener.ora添加(#后面为注释,不要添加进去)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(SID_NAME = ORCL) #这里是SID名
)
(SID_DESC =
(GLOBAL_DBNAME = PDBORCL)#这里是PDB数据库名
(SID_NAME = ORCL) #这里是SID名
)
)
tnsname.ora添加
PDBORCL=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT =1521))
)
(CONNECT_DATA =
(SERVICE_NAME = PDBORCL) #这里是PDB数据库名
)
)
2.重启监听(需要管理员权限)
lsnrctl reload
#也可以关闭再重启
lsnrctl stop
lsnrctl start
3.检查JDBC代码
注意:连接PDB时,1521端口号后面不是冒号:,而是斜线/
例如
String url = "jdbc:oracle:thin:@//localhost:1521/pdborcl";
转载于:https://www.cnblogs.com/gsls200808/p/4405499.html