java 连Oracle集群

Java連oracle庫—(數據庫在改為集群之后URL的相應調整)

出于系統性能以及安全方面考慮﹐我們工廠的其中一系統的數據庫的方式改為集群方式。這樣我們的JAVA系統的連庫方式也要改動﹐因以前沒有使用過集群數據庫﹐也沒有相應的資料﹐系統就暫時采用連接集群中的一台電腦。

經過測試最后才知道﹐原來URL還可以以Oracle別名字串來連接數據庫。

問題最終得以解決。

Oracle 別名

原別名﹕

test =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 122.117.12.50)(PORT = 1521))

    )

    (CONNECT_DATA = (SID = test))

  )

集群方式別名﹕

test =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 112.117.12.50)(PORT = 1521))

      (ADDRESS = (PROTOCOL = TCP)(HOST = 112.117.12.51)(PORT = 1521))

      (LOAD_BALANCE = yes)

      (FAILOVER = yes)

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (INSTANCE_ROLE = PRIMARY)

      (FAILOVER_MODE =

        (TYPE = SESSION)

        (METHOD = BASIC)

      )

      (SERVICE_NAME = test)

    )

  )

Java連庫URL方式變更如下

原方式﹕

jdbc.url=jdbc:oracle:thin:@112.117.12.50:1521:test

改為集群后的方式﹕

jdbc.url=jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 112.117.12.50)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 112.117.12.51)(PORT = 1521))(LOAD_BALANCE = yes)(FAILOVER = yes))(CONNECT_DATA = (SERVER = DEDICATED)(INSTANCE_ROLE = PRIMARY)(FAILOVER_MODE = (TYPE = SESSION)(METHOD = BASIC))(SERVICE_NAME = test)))

 

原文地址:http://blog.163.com/xin428@126/blog/static/52957110201002832940697/

你可能感兴趣的:(oracle)