A new arangodb-java-driver is out now, it’s on github. The driver is available for ArangoDB from version 2.2 onwards.
How to include the driver in your application ?
The driver is available as maven artifact. To add the driver to your project with maven, add the following code to your pom.xml:
1 2 3 4 5 6 7 8 9 |
<dependencies> <dependency> <groupId>com.arangodb</groupId> <artifactId>arangodb-java-driver</artifactId> <version>2.2</version> </dependency> .... </dependencies> |
Usage
So you included the driver to your application, how can you use it? First of all you have to configure the driver. You can either import a properties file or use the configuration object. We will focus on the most important properties:
First we create an instance of the configuration object ..
1 2 |
ArangoConfigure configure = new ArangoConfigure(); |
Lets say we have an ArangoDB instance running under http://123.456.789.10:8529
and we want to configure the driver to talk to that database. Furthermore we expect that a database “testDatabase” exists and want to use it as the default database:
1 2 3 4 |
configure.setHost("123.456.789.10"); configure.setPort(8529); configure.setDefaultDatabase("testDatabase"); |
Alternatively you can create a properties file and import it to the configuration object:
File /config/arango.properties:
1 2 3 4 |
port=8529 host=123.456.789.10 defaultDatabase=testDatabase |
Import the file:
1 2 |
configure.loadProperties("/config/arango.properties"); |
Now we can use this configuration to instantiate the driver:
1 2 |
ArangoDriver driver = new ArangoDriver(configure); |
Now you can use the ArangoDriver class to communicate with your ArangoDB.