2017  Kodetalk | Feedback | Privacy Policy | Terms | About

How to create a collection in arangodb and insert a document in arangodb using java code?

Now i want to create a new collection and insert a document in that collection using java driver. How will i do that?

Add the arangodb java driver


Now get the connection from arangodb [for reference click here]

Now to create a new collection try as below:

ArangoDBConnection.getDB().createCollection(<Collection name>);

and to insert a new document using java driver try as below:

BaseDocument baseDocument = new BaseDocument();
baseDocument.addAttribute("_key", "Moe");
baseDocument.addAttribute("firsrname", "Moe");
// keep adding more if required

ArangoDBConnection.getDB().createDocument(<Collection name>, baseDocument);

It will work for you.

Answer is