Srijan Sharma Srijan Sharma - 10 months ago 99
Java Question

Adding data to JanusGraph database

I had to use JanusGraph to retrieve and add data to it from java program. But i don't know how do i connect to a particular graph of db.Below is the code that i am using to insert data in the db but when i try to see the data from gremlin console, i cannot find the same data.

JanusGraph graph ="conf/");
GraphTraversalSource g = graph.traversal();

graph.addVertex("psid",psid,"firstname",firstname,"last_name",lastname, "locale", locale ,"timezone",timezone, "gender" ,gender,"channel_id",channel_id);

Gremlin query that i am doing:

gremlin> JanusGraph graph ="conf/");
gremlin> GraphTraversalSource g = graph.traversal();
gremlin> g.V().count()

count query gives 0 as output and i cannot find any data in the db.

Answer Source

Did you commit your graph transaction after adding the vertex? Till the time you do not commit a transaction it stays in memory instance and is not committed to the graph. Commit using:


Try again to query the graph through gremlin after executing the above line of code. Your vertex should now be there on the graph.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download