Using the database - shesse/h2ha GitHub Wiki

You can access the database from any Java application using the JDBC driver com.shesse.jdbcproxy.Driver.

The JDB URL has the following form:

jdbc:h2ha:tcp://machine-a,machine-b/mydbname

In fact, the URL is constructed after the original H2 TCP URL.

  • it uses 'h2ha' instead of 'h2'
  • the database name my be followed by database parameters as defined for H2 URLs
  • each machine name may be followed by :port if you want to change the H2 default (9092)
  • you may specify only a single machine if you are using H2HA in standalone mode

Note, that the H2 driver itself also has the possibility to specify multiple hosts separated by comma. This kind of setup may even work for you. However, it is meant for the application level clustering built into H2 and tries to tell the database engine that application level clustering is being used - which is not true for H2HA.