JDBC URL for connecting to a DB in a cluster configuration with spring-boot.
Oracle RAC
String DB_URL= "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=" +
"(LOAD_BALANCE=OFF)(FAILOVER=ON)" +
"(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=port1))" +
"(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=port2)))" +
"(CONNECT_DATA=(SERVICE_NAME=service_name)))"
By combining the above settings of LOAD_BALANCE = ON and FAILOVER = ON, the two functions of "load balancing" and "connection failover" are enabled.
When ʻapplication.properties` is specified, describe as follows.
spring.datasource.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=testDB)))
spring.datasource.username=user
spring.datasource.password=password
You can use the MariaDB JDBC driver's automatic failover feature to quickly switch between master and replica under failover conditions.
There are two ways to specify a JDBC URL: specify the Aurora DB cluster endpoint directly, or specify both the master and replica endpoints.
String DB_URL = "jdbc:mariadb:aurora//auroradbcluster.auroradbtest.com::3306/testDB";
When ʻapplication.properties` is specified, describe as follows.
spring.datasource.url=jdbc:mariadb:aurora//auroradbcluster.auroradbtest.com::3306/testDB
spring.datasource.username=user
spring.datasource.password=password
String DB_URL = "jdbc:mariadb:aurora//rds.auroradbtest.com:3306,rds-ro.auroradbtest.com:3306/testDB";
When ʻapplication.properties` is specified, describe as follows.
spring.datasource.url=jdbc:mariadb:aurora//rds.auroradbtest.com:3306,rds-ro.auroradbtest.com:3306/testDB
spring.datasource.username=user
spring.datasource.password=password
Recommended Posts