Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.apache.commons.configuration.BaseConfiguration;
- import org.apache.tinkerpop.gremlin.structure.Graph;
- import org.apache.tinkerpop.gremlin.structure.T;
- import org.apache.tinkerpop.gremlin.structure.Vertex;
- import org.umlg.sqlg.structure.SqlgGraph;
- import java.util.Iterator;
- import java.util.List;
- public class GremlinJenaTest2 {
- public static void main(String[] arg) {
- BaseConfiguration conf = new BaseConfiguration();
- conf.setProperty("jdbc.url", "jdbc:postgresql://localhost:5432/sqlgraphdb");
- conf.setProperty("jdbc.username", "batman");
- conf.setProperty("jdbc.password", "password");
- Graph g = SqlgGraph.open(conf);
- g.addVertex(T.label, "A", "name", "halo");
- g.tx().commit();
- List<Vertex> vertices = g.traversal().V().hasLabel("A").toList();
- System.out.println(vertices.size());
- for(Vertex anObject : vertices){
- System.out.println(anObject.label());
- }
- try {
- g.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment