Note that there are some explanatory texts on larger screens.

plurals
  1. POError while retrieving neo4j node data through java
    primarykey
    data
    text
    <p>I have loaded about 60k nodes into neo4j through talend. I want to get access to these nodes through java. Java code is only able to fetch a single node which comes with neo4j itself i.e. 0th node. </p> <p>My Java code is :</p> <pre><code>package com.Neo4J; 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 javax.naming.spi.DirStateFactory.Result; 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.impl.util.FileUtils; import org.neo4j.tooling.GlobalGraphOperations; public class CaseNeo4J { private static final String DB_PATH = "data/graph.db"; GraphDatabaseService graphDataService; String nodeResult, resultString, columnsString; String rows = ""; public static void main(String args[]) { CaseNeo4J neoobj = new CaseNeo4J(); neoobj.connect(); } void connect() { graphDataService = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH); Transaction transaction = graphDataService.beginTx(); try { ExecutionEngine engine = new ExecutionEngine(graphDataService); ExecutionResult result = engine.execute("START n = node(0) return n"); System.out.println(result.dumpToString()); } finally { transaction.finish(); } } } </code></pre> <p>As you can see in CQL I am trying to retireve node(0) which is giving me correct result as </p> <pre><code>+-----------+ | n | +-----------+ | Node[0]{} | +-----------+ 1 row </code></pre> <p>But as soon as I give query like <strong>START n = node(1) return n</strong> it throws errors as-</p> <pre><code>Exception in thread "main" org.neo4j.cypher.EntityNotFoundException: Node 1 not found at org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.getById(GDSBackedQueryC ontext.scala:80) at org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.getById(GDSBackedQueryC ontext.scala:48) at org.neo4j.cypher.internal.executionplan.builders.NodeByIdBuilder$$anonfun$org$neo4j$cypher$ internal$executionplan$builders$NodeByIdBuilder$$f$1$1.apply(NodeByIdBuilder.scala:41) at org.neo4j.cypher.internal.executionplan.builders.NodeByIdBuilder$$anonfun$org$neo4j$cypher$ internal$executionplan$builders$NodeByIdBuilder$$f$1$1.apply(NodeByIdBuilder.scala:41) at org.neo4j.cypher.internal.executionplan.builders.GetGraphElements$.org$neo4j$cypher$interna l$executionplan$builders$GetGraphElements$$castElement$1(GetGraphElements.scala:30) at org.neo4j.cypher.internal.executionplan.builders.GetGraphElements$$anonfun$getElements$3.ap ply(GetGraphElements.scala:40) at scala.collection.Iterator$$anon$11.next(Iterator.scala:328) at scala.collection.Iterator$$anon$11.next(Iterator.scala:328) at scala.collection.Iterator$$anon$13.next(Iterator.scala:372) at org.neo4j.cypher.internal.ClosingIterator$$anonfun$next$1.apply(ClosingIterator.scala:44) at org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterator.scala:86) at org.neo4j.cypher.internal.ClosingIterator.next(ClosingIterator.scala:43) at scala.collection.Iterator$class.foreach(Iterator.scala:727) at org.neo4j.cypher.internal.ClosingIterator.foreach(ClosingIterator.scala:31) at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48) at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:178) at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45) at scala.collection.TraversableOnce$class.to(TraversableOnce.scala:259) at org.neo4j.cypher.internal.ClosingIterator.to(ClosingIterator.scala:31) at scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:243) at org.neo4j.cypher.internal.ClosingIterator.toList(ClosingIterator.scala:31) at org.neo4j.cypher.PipeExecutionResult.eagerResult(PipeExecutionResult.scala:100) at org.neo4j.cypher.PipeExecutionResult.dumpToString(PipeExecutionResult.scala:103) at org.neo4j.cypher.PipeExecutionResult.dumpToString$lzycompute(PipeExecutionResult.scala:143) at org.neo4j.cypher.PipeExecutionResult.dumpToString(PipeExecutionResult.scala:140) at org.neo4j.cypher.javacompat.ExecutionResult.dumpToString(ExecutionResult.java:102) at com.Neo4J.CaseNeo4J.connect(CaseNeo4J.java:45) at com.Neo4J.CaseNeo4J.main(CaseNeo4J.java:32) </code></pre> <p>But if I ran <strong>START n = node(1) return n</strong> this query in web UI of neo4j shell it gives me correct result.</p> <p>Is there any idea on this? I will really appreciate if I get some solution here. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload