jdbc.url配置為:
jdbc:oracle:thin:@xxx.xx.xx.xx:1521:orclpdb
報錯:
java.sql.SQLException: Listenerrefused the connection with the following error:
ORA-12505, TNS:listener does notcurrently know of SID given in connect descriptor
通過sqlplus是正常的,上網找到:
https://www.cnblogs.com/pcbaby-ch/p/jdbc-connect-oracle12c-pdb-cdb.html
內容為:
4.3 jdbc連接字符串引發問題: l jdbc連接cdb數據庫時,url兼容2種模式: ü "jdbc:oracle:thin:@192.168.75.131:1521:oracle12c" ü "jdbc:oracle:thin:@192.168.75.131:1521/oracle12c" l jdbc連接pdb數據庫時url必須使用:" jdbc:oracle:thin:@192.168.75.131:1521/oracle12c"格式,若使用傳統格式" jdbc:oracle:thin:@192.168.75.131:1521:oracle12c"則會報一下錯誤: java.sql.SQLException: Listenerrefused the connection with the following error: ORA-12505, TNS:listener does notcurrently know of SID given in connect descriptor
看到自己的就是pdb(還沒有去看資料什么是pdb),按他說的調整為: jdbc:oracle:thin:@xxx.xx.xx.xx:1521/orclpdb
連接正常