Driver setup

How to connect your Java application to an ArangoDB server, as well as important configuration settings and information about the driver

The driver can be configured and instantiated using com.arangodb.ArangoDB.Builder:

ArangoDB arangoDB = new ArangoDB.Builder()
        // ...

To customize the configuration properties can be set programmatically in the builder:

ArangoDB arangoDB = new ArangoDB.Builder()
        // ...

or providing an implementation of com.arangodb.config.ArangoConfigProperties to the builder:

ArangoConfigProperties props = ...
ArangoDB arangoDB = new ArangoDB.Builder()
        // ...

Implementations of com.arangodb.config.ArangoConfigProperties could supply configuration properties coming from different sources, eg. system properties, remote stores, frameworks integrations, etc. An implementation for loading properties from local files is provided by ArangoConfigProperties.fromFile() and its overloaded variants.

To read config properties prefixed with arangodb from file (as in version 6):

// ## src/main/resources/
// arangodb.hosts=
// arangodb.password=test
// ...

ArangoConfigProperties props = ArangoConfigProperties.fromFile();

To read config properties from file, where the config properties are prefixed with adb:

// ## src/main/resources/
// adb.hosts=
// adb.password=test
// ...

ArangoConfigProperties props = ArangoConfigProperties.fromFile("", "adb");

Here are examples to integrate configuration properties from different sources:


ArangoDB.Builder has the following configuration methods:

  • host(String, int): adds a host (hostname and port) to connect to, multiple hosts can be added
  • protocol(Protocol): communication protocol, possible values are: VST, HTTP_JSON, HTTP_VPACK, HTTP2_JSON, HTTP2_VPACK, (default: HTTP2_JSON)
  • timeout(Integer): connection and request timeout (ms), (default 0, no timeout)
  • user(String): username for authentication, (default: root)
  • password(String): password for authentication
  • jwt(String): JWT for authentication
  • useSsl(Boolean): use SSL connection, (default: false)
  • sslContext(SSLContext): SSL context
  • verifyHost(Boolean): enable hostname verification, (HTTP only, default: true)
  • chunkSize(Integer): VST chunk size in bytes, (default: 30000)
  • maxConnections(Integer): max number of connections per host, (default: 1 VST, 1 HTTP/2, 20 HTTP/1.1)
  • connectionTtl(Long): time to live of an inactive connection (ms), (default: 30_000 for HTTP, no TTL for VST)
  • keepAliveInterval(Integer): VST keep-alive interval (s), (default: no keep-alive probes will be sent)
  • acquireHostList(Boolean): acquire the list of available hosts, (default: false)
  • acquireHostListInterval(Integer): acquireHostList interval (ms), (default: 3_600_000, 1 hour)
  • loadBalancingStrategy(LoadBalancingStrategy): load balancing strategy, possible values are: NONE, ROUND_ROBIN, ONE_RANDOM, (default: NONE)
  • responseQueueTimeSamples(Integer): amount of samples kept for queue time metrics, (default: 10)
  • compression(Compression): the content-encoding and accept-encoding to use for HTTP requests, possible values are: NONE, DEFLATE, GZIP, (default: NONE)
  • compressionThreshold(Integer): the minimum HTTP request body size (in bytes) to trigger compression, (default: 1024)
  • compressionLevel: compression level between 0 and 9, (default: 6)
  • serde(ArangoSerde): serde to serialize and deserialize user-data
  • protocolConfig(ProtocolConfig): configuration specific for the used protocol provider implementation

HTTP Protocol Provider Configuration

The ProtocolConfig for the default HTTP protocol provider can be created via:

  // ...

and configured using the following builder methods:

  • vertx(Vertx): Vert.x instance to use. If not set, a new instance is created.

For example, to reuse the existing Vert.x instance:


Config File Properties

ArangoConfigProperties.fromFile() reads config properties prefixed with arangodb from file (as in version 6). Different prefix and file name can be specified using its overloaded variants.

The properties read are:

  • hosts: comma-separated list of <hostname>:<port> entries
  • timeout
  • user
  • password
  • jwt
  • useSsl
  • verifyHost
  • chunkSize
  • maxConnections
  • connectionTtl
  • keepAliveInterval
  • acquireHostList
  • acquireHostListInterval
  • loadBalancingStrategy: NONE, ROUND_ROBIN or ONE_RANDOM
  • responseQueueTimeSamples
  • compression: NONE, DEFLATE or GZIP
  • compressionThreshold
  • compressionLevel


To use SSL, you have to set the configuration useSsl to true and set a SSLContext (see example code ).

ArangoDB arangoDB = new ArangoDB.Builder()

Connection Pooling

The driver keeps a pool of connections for each host, the max amount of connections is configurable.

Inactive connections are released after the configured connection time-to-live (ArangoDB.Builder.connectionTtl(Long)) or when the driver is shut down:


Thread Safety

The driver can be used concurrently by multiple threads. All the following classes are thread safe:

  • com.arangodb.ArangoDB
  • com.arangodb.ArangoDatabase
  • com.arangodb.ArangoCollection
  • com.arangodb.ArangoGraph
  • com.arangodb.ArangoVertexCollection
  • com.arangodb.ArangoEdgeCollection
  • com.arangodb.ArangoView
  • com.arangodb.ArangoSearch

Any other class should not be considered thread safe. In particular classes representing request options (package com.arangodb.model) and response entities (package com.arangodb.entity) are not thread safe.

Fallback hosts

The driver supports configuring multiple hosts. The first host is used to open a connection to. When this host is not reachable the next host from the list is used. To use this feature just call the method host(String, int) multiple times.

ArangoDB arangoDB = new ArangoDB.Builder()
  .host("host1", 8529)
  .host("host2", 8529)

The driver is also able to acquire a list of known hosts in a cluster. For this the driver has to be able to successfully open a connection to at least one host to get the list of hosts. Then it can use this list when fallback is needed. To enable this feature:

ArangoDB arangoDB = new ArangoDB.Builder()

Load Balancing

The driver supports load balancing for cluster setups in two different ways.

The first one is a round robin load balancing where the driver iterates through a list of known hosts and performs every request on a different host than the request before.

ArangoDB arangoDB = new ArangoDB.Builder()

The second load balancing strategy picks a random host from host list (configured or acquired) and sticks to it as long as the connection is open.

ArangoDB arangoDB = new ArangoDB.Builder()

Connection time to live

The driver supports setting a TTL (time to live) for connections:

ArangoDB arango = new ArangoDB.Builder()
  .connectionTtl(5 * 60 * 1000) // ms

In this example, inactive connections are closed after 5 minutes.

The default TTL for HTTP connections is 30 seconds, while it is null for VST connections.

If set to null, no automatic connection closure is performed.

VST Keep-Alive

The driver supports setting keep-alive interval (in seconds) for VST connections (but VST is not supported from ArangoDB v3.12.0 onward). If set, every VST connection performs a no-op request at the specified intervals, to avoid to be closed due to inactivity by the server (or by the external environment, e.g. firewall, intermediate routers, operating system, … ).

ArangoDB arangoDB = new ArangoDB.Builder()
        .keepAliveInterval(1_800) // 30 minutes

If not set or set to null (default), no keep-alive probes will be sent.