1、Java JDBC链接Oracle11G R2时遇到了如下错误:
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
192.168.0.11:1521:ORCLDB
2、通过PLSQL Developer 能正常链接
网上查阅相关资料,得知java jdbc链接oracle 不能使用service_name,需要使用INSTANCE_NAME
使用SQL查询 SELECT INSTANCE_NAME FROM v$instance;
将查询结果替换jdbc链接字符串中的ORCLDB即可.