1

I think agens-graph is a good Graph Database , and i make some demo. But it doesn't work . some body help me?

Class.forName("net.bitnine.agensgraph.Driver");
        String connectionString = "jdbc:agensgraph://127.0.0.1:5433/agens";
        Properties properties = new Properties();
        properties.setProperty("username","agens");
        properties.setProperty("password","123456");
        properties.setProperty("graph_path","graphname");
        properties.setProperty("user","agens");
        Connection conn = DriverManager.getConnection(connectionString,properties);
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(
                "MATCH (n:person {name: 'Tom'})-[:knows]->(m:person) RETURN n.name AS n, m.name AS m;");
        while (rs.next()) {
            Vertex friend = (Vertex) rs.getObject(1);
            System.out.println(friend.getString("n"));
            System.out.println(friend.getInt("m"));
        }

console:

Exception in thread "main" org.postgresql.util.PSQLException: ERROR: graph_path is NULL

Suggesting:Use SET graph_path at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:300) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:301) at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:287) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:264) at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:231) at net.bitnine.agensgraph.jdbc.AgStatement.executeQuery(AgStatement.java:43) at agensgraph.AgensgraphTest.main(AgensgraphTest.java:18)

juntao liu
  • 61
  • 1
  • 1
  • 3

1 Answers1

1

You need to set graph you want the query to be executed on:

ResultSet rs = stmt.executeQuery(
             "SET graph_path=mygraph;"+
             "MATCH (n:person {name: 'Tom'})-[:knows]->(m:person) RETURN n.name AS n, m.name AS m;"
);

Other possibility is to set the default graph path for a user:

ALTER USER agens SET graph_path = 'mygraph';
merqurio
  • 931
  • 12
  • 24