Java服务连接Oracle 10.2数据库时报异常,PL/SQL却可以正常登录使用
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
ORA-12505:TNS: 监听程序当前无法识别连接描述符中所给出的 SID
原有Springboot连接地址如下
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:data
需要改动为
jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost(PORT=1521))(LOAD_BALANCE=yes))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=data)))
也可以简写为
jdbc:oracle:thin:@(description=(address=(protocol=tcp)(port=1521)(host=localhost))(connect_data=(service_name=data)))
其中address的三个属性protocol,port,host顺序可以变化,大小写均可以。结构为
description
address
protocol
host
port
connect_data
service_name