Ritesh Kaushik
Ritesh Kaushik

Reputation: 735

Using java to execute gremlin queries on Gremlin server hosted on amazon EC2

I have used this link to create DynamoDB Storage Backend for Titan with Gremlin Server on Amazon EC2 by using a AWS CloudFormation template. This worked fine and i am able to get the output.

I want to connect and access the titan db created above using java and execute queries from my java program. Need help in doing so.

I am able to do so using nodejs code below:

 var Gremlin = require('gremlin');

// Will open a WebSocket to ws://localhost:8182 by default
const client = Gremlin.createClient();

console.log(JSON.stringify(client));


client.execute('g.addV("FirstVertex","Value")', (err, results) => {
  if (!err) {
console.log(results); // notice how results is *always* an array
  }
 console.log(err);
});

client.execute('g.V()', (err, results) => {
if (!err) {
console.log(results); // notice how results is *always* an array
}
});

How to do same thing using java websocket ?

Upvotes: 2

Views: 1667

Answers (1)

Jason Plurad
Jason Plurad

Reputation: 6792

There is documentation in Apache TinkerPop on using the Java driver to connect to a Gremlin Server. You can also see an example using Titan here https://github.com/pluradj/titan-tp3-driver-example

Upvotes: 1

Related Questions