home shape

ArangoDB Java Driver: Simplifying Database Interactions

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:

<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 ..

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:

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:

port=8529 host=123.456.789.10 defaultDatabase=testDatabase 

Import the file:

configure.loadProperties("/config/arango.properties"); 

Now we can use this configuration to instantiate the driver:

ArangoDriver driver = new ArangoDriver(configure); 

Now you can use the ArangoDriver class to communicate with your ArangoDB.

Author

  • Frank Celler

    Frank is both entrepreneur and backend developer, developing mostly memory databases for two decades. He is the CTO and co-founder of ArangoDB. Try to challenge Frank asking him questions on C, C++ and MRuby. Besides Frank organizes Cologne’s NoSQL group & is an active member of NoSQL community.

Frank Celler

Frank Celler

Frank is both entrepreneur and backend developer, developing mostly memory databases for two decades. He is the CTO and co-founder of ArangoDB. Try to challenge Frank asking him questions on C, C++ and MRuby. Besides Frank organizes Cologne’s NoSQL group & is an active member of NoSQL community.

Leave a Comment

Get the latest tutorials, blog posts and news: