Properties for connecting to high-availability cluster servers through SQLHOST file group entries
You can define sqlhost group entries, so that your application connection attempt is always directed to the primary server of a high-availability cluster, even if failover occurs.
To connect to the primary server of a high-availability
cluster, include the following properties in the connection URL or
DataSource:
ONEDB_SERVER=group_name SQLH_TYPE=FILE SQLH_FILE=sqlhosts USER=user_name PASSWORD=password
An exception is thrown if the JDBC driver cannot find a primary server in the group.
Enforcing connections to the primary server is enabled for HCL OneDB™, Version 9.40.xC6 and later only.
Example: Connecting to the primary server of a high-availability cluster through SQLHOST file group entries
In this example,
you have the following system setup:
- You have a high-availability cluster (my_cluster) that
is composed of four servers:
- server_1 (primary), on host1.example.com
- server_2 (shared-disk secondary), on host1.example.com
- server_3 (HDR), on host2.example.com
- server_4 (Remote-standalone secondary), on host3.example.com
- The user name on all cluster servers is my_user.
- The password on all cluster servers is my_password.
- You have a Java™ application
server on host4.example.com. The server uses the following sqlhost file
entries:
#dbservername nettype hostname servicename options my_servers - - c=1,e=server_4 server_1 onsoctcp host1.example.com port_1 g=my_servers server_2 onsoctcp host1.example.com port_2 g=my_servers server_3 onsoctcp host2.example.com port_3 g=my_servers server_4 onsoctcp host3.example.com port_4 g=my_servers
To connect the Java application
client to the primary server of my_cluster, use the following
URL:
jdbc:onedb://ONEDB_SERVER=my_servers; SQLH_TYPE=FILE;SQLH_FILE=sqlhosts; USER=my_user_name;PASSWORD=my_password