這篇文章主要介紹了JDBC連接集群數據庫的方法,有需要的朋友可以參考一下
在連接數據庫的url地址有點不一樣 代碼如下: jdbc:oracle:thin:@(DESCRIPTION= (LOAD_BALANCE=on) (ADDRESS_LIST= (ADDRESS=(PROTOCOL=TCP)(HOST=IP1)(PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=IP2)(PORT=1521)) ) (CONNECT_DATA=(SERVICE_NAME=服務名))) url=jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.77)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.91)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = hostIp3)(PORT = 1521)) ) (CONNECT_DATA =(SERVICE_NAME = APPDB))) username=imei_app password=imei_app