gpt4 book ai didi

java - Neo4j 数据检索中出现空点异常

转载 作者:行者123 更新时间:2023-12-01 10:24:49 26 4
gpt4 key购买 nike

我有以下代码。

GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
GraphDatabaseService db= dbFactory.newEmbeddedDatabase("C:/Users/shadid/Documents/Neo4j/DB");

ExecutionEngine execEngine = new ExecutionEngine(db, null);
ExecutionResult execResult = execEngine.execute("MATCH (mat:TheMatrix) RETURN mat");
String results = execResult.dumpToString();
System.out.println(results);

我收到一个空点异常。我尝试在 neo4j 命令行中运行该命令。所以数据确实存在。我不太确定错误在哪里。 Neo4j 中的菜鸟,所以有人可以帮助我吗

这是我遇到的错误

Exception in thread "main" java.lang.NullPointerException
at org.neo4j.cypher.internal.CypherCompiler.(CypherCompiler.scala:69)
at org.neo4j.cypher.ExecutionEngine.createCompiler(ExecutionEngine.scala:237)
at org.neo4j.cypher.ExecutionEngine.(ExecutionEngine.scala:64)
at App.Main.main(Main.java:53)

最佳答案

刚刚找到了一种更直观的方法来做同样的事情,而且它很有效!!!

try ( Transaction ignored = db.beginTx();
Result result = db.execute( "MATCH (n:TheIronGiant) RETURN n.`title: `" ) )
{
String rows ="";
while ( result.hasNext() )
{
Map<String,Object> row = result.next();

for ( Entry<String,Object> column : row.entrySet() )
{
rows += column.getKey() + ": " + column.getValue() + "; ";
}
rows += "\n";
}
System.out.println(rows);
}

关于java - Neo4j 数据检索中出现空点异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35399808/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com