1. 程式人生 > >JDBC連線ORACLE需要注意:與 /

JDBC連線ORACLE需要注意:與 /

本文轉自:https://blog.csdn.net/chinahuanghuajun/article/details/79035092

格式一: Oracle JDBC Thin using a Service_Name:    
jdbc:oracle:thin:@//192.168.6.66:1521/rac  (資料庫的服務名Service_name:rac)  
  
格式二: Oracle JDBC Thin using an SID:    
jdbc:oracle:thin:@192.168.6.66:1521:rac1   (資料庫的例項名SID:rac1)  
  
格式三:Oracle JDBC Thin using  連線串      (一般在連線oracle RAC使用)
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.66)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=rac)(INSTANCE_NAME=rac1)))
或者
 jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.66)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.68)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=rac)))
或者 

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.66)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.68)(PORT=1521))(FAILOVER=on)(LOAD_BALANCE=on))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=rac)))

注意:使用SID和SERVICE_NAME方式的區別"/" 與 ":"很多人沒有注意.