【JDBC】TNS:listener does not currently know of SID given in connect descriptor

报错内容:

  e.getMessage()=== Listener refused the connection with the following error: ORA-12505,

  TNS:listener does not currently know of SID given in connect descriptor

//ORA-12505: TNS: 监听程序当前无法识别连接描述符中所给出的SID

 

更换数据源时,出现了以上错误。

 

说明给到的sid有误,很有可能就是服务名和sid混淆使用。

在网上搜到了以下三种JDBC写法:

格式一:jdbc:oracle:thin:@//<host>:<port>/<service_name>
格式二:jdbc:oracle:thin:@<host>:<port>:<SID>
格式三:jdbc:oracle:thin:@<TNSName>


第一种是监听服务名,第二种是监听sid服务

原始数据源使用的是sid的写法,因此替换时把服务名当做了sid,但新数据源给的是service_name,所以发生了上述错误

 

解决方案:

按照格式一的方式,修改jdbc的写法后,可以正常访问。

 



posted @ 2022-01-18 20:16  IIIID  阅读(1585)  评论(0编辑  收藏  举报