Guest User

Untitled

a guest
Apr 13th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import org.apache.commons.configuration.BaseConfiguration;
  2. import org.apache.tinkerpop.gremlin.structure.Graph;
  3. import org.apache.tinkerpop.gremlin.structure.T;
  4. import org.apache.tinkerpop.gremlin.structure.Vertex;
  5. import org.umlg.sqlg.structure.SqlgGraph;
  6.  
  7. import java.util.Iterator;
  8. import java.util.List;
  9.  
  10. public class GremlinJenaTest2 {
  11.  
  12. public static void main(String[] arg) {
  13. BaseConfiguration conf = new BaseConfiguration();
  14. conf.setProperty("jdbc.url", "jdbc:postgresql://localhost:5432/sqlgraphdb");
  15. conf.setProperty("jdbc.username", "batman");
  16. conf.setProperty("jdbc.password", "password");
  17. Graph g = SqlgGraph.open(conf);
  18. g.addVertex(T.label, "A", "name", "halo");
  19. g.tx().commit();
  20. List<Vertex> vertices = g.traversal().V().hasLabel("A").toList();
  21. System.out.println(vertices.size());
  22.  
  23.  
  24. for(Vertex anObject : vertices){
  25. System.out.println(anObject.label());
  26. }
  27.  
  28. try {
  29. g.close();
  30. } catch (Exception e) {
  31. e.printStackTrace();
  32. }
  33. }
  34. }
Add Comment
Please, Sign In to add comment