0
我想從使用事務處理程序的neo4j DB中檢索數據。我已經添加了以下jar文件在java中執行密碼查詢異常
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.HashMap;
import org.neo4j.cypher.javacompat.ExecutionEngine;
import org.neo4j.cypher.javacompat.ExecutionResult;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.helpers.collection.IteratorUtil;
import org.neo4j.kernel.EmbeddedGraphDatabase;
import org.neo4j.kernel.impl.util.FileUtils;
public class SampleNeo4j {
private static final String DB_PATH = "C:\\Users\\amritak\\neo4jTest";
ExecutionResult result;
ExecutionResult resultString;
String columnsString;
String nodeResult;
String nodeResultAge;
String rows = "";
CypherParser parser = new CypherParser();
Query query;
void run() {
GraphDatabaseService db = new EmbeddedGraphDatabase(DB_PATH);
db.registerTransactionEventHandler(new WarehouseTransactionEventHandler());
query = parser.parse("start n=node(*) return n");
ExecutionEngine engine = new ExecutionEngine(db);
result = engine.execute(query);
System.out.println("col string");
System.out.println(result);
resultString = engine.execute(query);
System.out.println("With Out Dump : "+resultString);
List<String> columns = resultString.columns();
System.out.println(columns);
Iterator<Node> n_column = resultString.columnAs("n");
for (Node nodes : IteratorUtil.asIterable(n_column)) {
// note: we're grabbing the name property from the node,
// not from the n.name in this case.
nodeResult = nodes + ": " + nodes.getProperty("name");
nodeResultAge = nodes + ": " + nodes.getProperty("age");
System.out.println(nodeResult);
System.out.println(nodeResultAge);
}
for (Map<String, Object> row : resultString) {
for (Entry<String, Object> column : row.entrySet()) {
rows += column.getKey() + ": " + column.getValue() + "; ";
}
rows += "\n";
}
System.out.println(rows);
db.shutdown();
}
public static void main(String args[]) {
SampleNeo4j javaQuery = new SampleNeo4j();
javaQuery.run();
}
}
雖然我經常收到同樣的錯誤
Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.augmentString(Ljava/lang/String;)Lscala/collection/immutable/StringOps;
at org.neo4j.cypher.parser.CypherParser.parse(CypherParser.scala:62)
at com.graphaware.tx.event.batch.api.SampleNeo4j.run(SampleNeo4j.java:45)
at com.graphaware.tx.event.batch.api.SampleNeo4j.main(SampleNeo4j.java:81)
這表明此錯誤是
query = parser.parse("start n=node(*) return n");
u能告訴我該怎麼做線刪除此錯誤?