2

我已使用this链接通过AWS CloudFormation模板为Amazon EC2上的Gremlin服务器创建DynamoDB存储后端。这工作得很好,我能够得到输出。使用java在亚马逊EC2上托管的Gremlin服务器上执行gremlin查询

我想连接和访问上面使用java创建的titan db并从我的java程序执行查询。需要帮助。

我能够做到这一点使用下面的代码的NodeJS:

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 
} 
}); 

如何使用Java的WebSocket做同样的事情?

回答