Javaoraclethin and oci Connection Methods for multi-database failover I. thin mode where URL is jdbc: oracle: thin: @ (DESCRIPTION (LOAD_BALANCEon) (ADDRESS (PROTOCOLTCP) (HOST127.0.0.1) (PORT1521) (ADDRESS (PROTOCOLTCP) (HOST10.132.111.14) (PORT1521) (CON
Java oracle thin and oci Connection Methods for multi-database failover I. thin mode where 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) (CON
Java oracle thin and oci Connection Methods for multi-database failover
I. thin Method
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 )))
LOAD_BALANCE = on indicates that the load is enabled, and java creates a session connection randomly;
LOAD_BANLANCE = off indicates that the load is disabled. java creates Session connections in sequence and only
When the first database fails and cannot be connected, the second database is selected for session connection.
Ii. oci Mode
1. Install the oracle client on the local machine where the specific program is deployed, specify the bin directory of the oracle client in the PATH, and copy
The jdbc driver in the oracle client is included in your 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 more information about the role of configuration parameters, see!
3. java jdbc connection
The URL is written as java: oracle: oci: @ ha_db.