Hello,I'm new to Neo4j. I tried this official example "Execute Cypher Queries from Java". Every thing was done as expected including the raw output of the query. However, I couldn't fetch the data, and it seems that the iteratorresult.columnAs("n")is empty in the following position.
Iterator<Node> n_column = result.columnAs("n");for( Node node : IteratorUtil.asIterable( n_column ) ){// note: we're grabbing the name property from the node,// not from the n.name in this case.nodeResult = node +": "+ node.getProperty("name");}Where is the problem?Thanks in advance.--
System.out.println(result.toString()); result.columnAs("n")package TestNeo4j1;
import java.util.Iterator;import java.util.List;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;
public class TestNeo4j1 {
public static void main(final String[] args) {
String DB_PATH = "C:/neo4j-community-1.9.M02/data/MyDB"; GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH); Transaction tx = graphDb.beginTx(); org.neo4j.cypher.javacompat.ExecutionEngine engine = new org.neo4j.cypher.javacompat.ExecutionEngine(graphDb); org.neo4j.cypher.javacompat.ExecutionResult result = engine.execute("START n=node:nodes(nodeName = \"Some Node Name\") RETURN n, n.nodeName");
// System.out.println(result.toString());
Iterator<Node> n_column = result.columnAs("n"); String nodeResult = ""; for (Node node : IteratorUtil.asIterable(n_column)) { nodeResult += node + ": " + node.getProperty("nodeName") + " " + node.getId() + "\n"; } System.out.println(nodeResult);
try { tx.success(); } finally { tx.finish(); } graphDb.shutdown(); }}Hello,I'm new to Neo4j. I tried this official example "Execute Cypher Queries from Java". Every thing was done as expected including the raw output of the query. However, I couldn't fetch the data, and it seems that the iteratorresult.columnAs("n")is empty in the following position.
Iterator<Node> n_column = result.columnAs("n");for( Node node : IteratorUtil.asIterable( n_column ) )
{// note: we're grabbing the name property from the node,// not from the n.name in this case.
<div class="container" style="margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: relative !important; right: aut...
Afficher le message d'origine
System.out.println(result.toString()); Iterator<Node> list_brands = result.columnAs("n"); --