Java Oracle thin and OCI connectivity for failover of multiple databases

Source: Internet
Author: User
Tags failover

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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.