转载自:http://www.calcprofit.com/blog/index.php/2010/10/11/jdbc%E8%BF%9E%E6%8E%A5%E6%8A%A5ora-12505%EF%BC%8Csid%E6%97%A0%E6%B3%95%E6%89%BE%E5%88%B0/
?
用JDBC连接ORACLE
jdbc:oracle:thin:@192.168.10.111:1521:ora10g
报错
java.sql.SQLException: 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.10.111:1521:ora10g
用下面这个串就是可以的
jdbc:oracle:oci8:@(description=(address=(host=192.168.10.111)(protocol=tcp)(port=1521))(connect_data=(service_name=ora10g)(server=DEDICATED)))
最后确认,该服务器是RAC,如果单联,需要用
jdbc:oracle:thin:@192.168.10.111:1521:ora10g1
or
jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.111)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.112)(PORT = 1521))(LOAD_BALANCE = yes)(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = ora10g)))
over.