Java Oracle thin and OCI connectivity for failover of multiple databases
First, Thin way
Where the URL is
jdbc:oracle:thin:@ (description= (Load_balance=on)
(Address= (PROTOCOL=TCP) (host=127.0.0.1) (port=1521))
(Address= (PROTOCOL=TCP) (host=10.132.111.14) (port=1521))
(Connect_data= (SERVICE_NAME=BOMC)))
Where load_balance=on means load is on, Java creates session connections in random ways;
Load_banlance=off indicates that the load is closed, and Java creates the session connection in a sequential fashion, only
A second database is selected for session connectivity when the first database fails to connect.
Ii. mode of OCI
1. Specific program deployment of the native need to install the Oracle client, and in the path path to specify the Oracle client Bin directory, and copy
The JDBC driver from the Oracle client is driven to its own project.
2. Configure the Tnsnames.ora file as follows:
ha_db =
(Description_list =
(load_balance = ON)
(FAILOVER = ON)
(DESCRIPTION =
(Address_list =
(Load_balance=off)
(Failover=on)
(ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT = 1521))
)
(Connect_data =
(service_name = BOMC)
(instance_name = BOMC)
(Failover_mode= (type=session) (Method=basic) (retries=4) (Delay=1))
)
)
(DESCRIPTION =
(Address_list =
(Load_balance=off)
(Failover=on)
(ADDRESS = (PROTOCOL = TCP) (HOST = 10.132.111.14) (PORT = 1521))
)
(Connect_data =
(service_name = BOMC)
(instance_name = BOMC)
(Failover_mode= (type=session) (Method=basic) (retries=4) (Delay=1))
)
)
(DESCRIPTION =
(Address_list =
(Load_balance=off)
(Failover=on)
(ADDRESS = (PROTOCOL = TCP) (HOST = 10.112.11.161) (PORT = 1521))
)
(Connect_data =
(service_name = BOMC)
(instance_name = BOMC)
(Failover_mode= (type=session) (Method=basic) (retries=4) (Delay=1))
)
)
)
For the role of configuration parameters please check the relevant information!
3. Java JDBC Connection
Where the URL is written as Java:oracle:oci: @ha_db