Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java org.postgresql.util.PSQLException:错误:图形路径为空_Java_Agens Graph - Fatal编程技术网

Java org.postgresql.util.PSQLException:错误:图形路径为空

Java org.postgresql.util.PSQLException:错误:图形路径为空,java,agens-graph,Java,Agens Graph,我认为agens-graph是一个很好的图形数据库,我做了一些演示。但它不起作用。有人帮我吗? Class.forName("net.bitnine.agensgraph.Driver"); String connectionString = "jdbc:agensgraph://127.0.0.1:5433/agens"; Properties properties = new Properties(); properties.setProper

我认为agens-graph是一个很好的图形数据库,我做了一些演示。但它不起作用。有人帮我吗?

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"));
        }
控制台:

Exception in thread "main" org.postgresql.util.PSQLException: ERROR: graph_path is NULL
建议:使用SET graph_path 位于org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477) 位于org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190) 位于org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:300) 位于org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428) 位于org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354) 位于org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:301) 位于org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:287) 位于org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:264) 位于org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:231) 位于net.bitnine.agensgraph.jdbc.AgStatement.executeQuery(AgStatement.java:43)
在agensgraph.AgensgraphTest.main(AgensgraphTest.java:18)

中,您需要设置要对其执行查询的图形:

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;"
);
另一种可能是为用户设置默认图形路径:

ALTER USER agens SET graph_path = 'mygraph';