jdbc
jdbc:postgresql://node1:port1,node2:port2/postgres?targetServerType=primary
jdbc:postgresql://node1:port1,node2:port2/postgres?targetServerType=preferSecondary
jdbc:postgresql://node1:port1,node2:port2/postgres?targetServerType=preferSecondary&loadBalanceHosts=true
jdbc:postgresql://node1:port1,node2:port2/postgres?targetServerType=any&loadBalanceHosts=true
libpq
libpq starting from PostgreSQL 10:
postgresql://host1:port1,host2:port2/postgres?target_session_attrs=read-write
postgresql://host1:port1,host2:port2/postgres?target_session_attrs=any
1)targetServerType = String
Allows opening connections to