无法执行在命令行中执行Neo4j查询的java程序



我们正在尝试执行一个运行Neo4j查询的程序。
使用NetBeans,执行成功。但是当我们使用cmd运行它时,它会给出以下错误-

C:>java -jar "C:UserssourabhDocumentsNetBeansProjectsfreeb2distfreeb2.ja
r"
org.neo4j.cypher.EntityNotFoundException: Node 1 not found
        at org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.g
etById(GDSBackedQueryContext.scala:80)
        at org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.g
etById(GDSBackedQueryContext.scala:48)
        at org.neo4j.cypher.internal.executionplan.builders.NodeByIdBuilder$$ano
nfun$org$neo4j$cypher$internal$executionplan$builders$NodeByIdBuilder$$f$1$1.app
ly(NodeByIdBuilder.scala:41)
        at org.neo4j.cypher.internal.executionplan.builders.NodeByIdBuilder$$ano
nfun$org$neo4j$cypher$internal$executionplan$builders$NodeByIdBuilder$$f$1$1.app
ly(NodeByIdBuilder.scala:41)
        at org.neo4j.cypher.internal.executionplan.builders.GetGraphElements$.or
g$neo4j$cypher$internal$executionplan$builders$GetGraphElements$$castElement$1(G
etGraphElements.scala:30)
        at org.neo4j.cypher.internal.executionplan.builders.GetGraphElements$$an
onfun$getElements$3.apply(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(Closi
ngIterator.scala:44)
        at org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterato
r.scala:86)
        at org.neo4j.cypher.internal.ClosingIterator.next(ClosingIterator.scala:
43)
        at org.neo4j.cypher.PipeExecutionResult.next(PipeExecutionResult.scala:1
59)
        at org.neo4j.cypher.PipeExecutionResult.next(PipeExecutionResult.scala:3
3)
        at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
        at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
        at scala.collection.convert.Wrappers$IteratorWrapper.next(Wrappers.scala
:30)
        at org.neo4j.cypher.PipeExecutionResult$$anon$1.next(PipeExecutionResult
.scala:75)
        at freeb2.Freeb2.main(Freeb2.java:308)
Exception in thread "main" org.neo4j.graphdb.TransactionFailureException: Unable
 to commit transaction
        at org.neo4j.kernel.TopLevelTransaction.finish(TopLevelTransaction.java:
137)
        at freeb2.Freeb2.main(Freeb2.java:620)
Caused by: javax.transaction.RollbackException: Failed to commit, transaction ro
lledback
        at org.neo4j.kernel.impl.transaction.TxManager.rollbackCommit(TxManager.
java:565)
        at org.neo4j.kernel.impl.transaction.TxManager.commit(TxManager.java:349
)
        at org.neo4j.kernel.impl.transaction.TransactionImpl.commit(TransactionI
mpl.java:134)
        at org.neo4j.kernel.TopLevelTransaction.finish(TopLevelTransaction.java:
127)
        ... 1 more
这是我们的代码-
public static void main(String[] args)
 {
     Transaction tx = graphDb.beginTx();
  try
  {
      tx.success();
   engine = new ExecutionEngine( graphDb );// HttpTransport httpTransport = new NetHttpTransport();
String x = "start root = node(1) return root";
result = engine.execute( x );
^^^^^ Error due to this line

我们所做的基本上是,使用NetBeans构建程序,并使用它在- To run this application from the command line without Ant, try: ...下生成的命令执行代码。

EntityNotFoundException: Node 1 not found

你必须先在你的图中插入数据,然后才能查询它。

关于如何导入数据的示例,请参阅neo4j.org和Rik的博客上的导入页面。

请通过Neo4j在线课程为您提供密码的安全基础(例如不建议使用节点id)

这是Jason C在问题的评论部分提到的DB_PATH的问题。
它是用绝对路径来固定的。

相关内容

  • 没有找到相关文章

最新更新