5.2. Connecting to the Database

Documentation

VoltDB Home » Documentation » Guide to Performance and Customization

5.2. Connecting to the Database

Client2 simplifies the process establishing and maintaining connections to the database. By default Client2 automates creating connections to all nodes of the cluster once a single connection is made, and reconnects as necessary as nodes leave and rejoin the cluster.

So, you can simply connect to one node of the cluster and the Client2 interface will take responsibility for connecting to other cluster nodes:

client.connectSync("localhost");

Or you can supply a list of nodes and the client will create a connection to the first it can reach, then establish connections to the rest of the cluster:

String[] servers = ["eeny","meeny","miny"];
client.connectSync(servers);