title: Galera cluster JDBC URL for automatic failover
body: <p>I've used <code>com.mysql.jdbc.Driver</code> with the following URL for load balancing and it worked:</p>
  
  <pre><code>jdbc:mysql:loadbalance://node1,node2,node3/mydb
  </code></pre>
  
  <p>Using the above URL, queries are randomly distributed among the three nodes. Now I need to have a <strong>failover</strong> setup in which all queries are sent to only and only one node and once that node is gone, the next available node should be selected for all queries thereafter.</p>
  
  <p>My cluster is a multimaster. This means that the new node after a failover still gets both read and write queries. The reason why I do not want load balancing is <a href="http://www.severalnines.com/blog/avoiding-deadlocks-galera-set-haproxy-single-node-writes-and-multi-node-reads" rel="nofollow">to reduce deadlock problems</a>.</p>
  
  <p>What JDBC URL do you think I should use?</p>
  
  <p><strong>P.S.</strong></p>
  
  <p>I've used <code>jdbc:mysql://node1,node2,node3/mydb</code> with <code>com.mysql.jdbc.ReplicationDriver</code> but it makes the selected node after a failover read-only.</p>