gpt4 book ai didi

java.lang.ClassCastException : org. neo4j.kernel.TopLevelTransaction

转载 作者:行者123 更新时间:2023-11-30 03:58:17 27 4
gpt4 key购买 nike

尝试 java 程序连接到 Neo4J 我收到以下错误

/home/mkgs/Desktop/placement/
Mar 21, 2014 2:53:41 PM org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog doInternalRecovery
INFO: Non clean shutdown detected on log [/home/mkgs/Desktop/placement/nioneo_logical.log.1Recovery started ...
Mar 21, 2014 2:53:42 PM org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog doInternalRecovery
INFO: Non clean shutdown detected on log [/home/mkgs/Desktop/placement/index/lucene.log.1]. Recovery started ...
Exception in thread "main" java.lang.ClassCastException: org.neo4j.kernel.TopLevelTransaction cannot be cast to javax.transaction.Transaction
at neo.main(neo.java:22)

java代码如下

//import javax.transaction.Transaction;

import javax.transaction.Transaction;
import org.neo4j.cypher.ExecutionEngine;
import org.neo4j.cypher.javacompat.ExecutionResult;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.kernel.EmbeddedGraphDatabase;

public class neo {
public static void main(String args[])
{
final String DB_PATH = "/home/mkgs/Desktop/placement/";
GraphDatabaseService graphDb;

System.out.println(DB_PATH);

graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);

Transaction tx = (Transaction) graphDb.beginTx();

try {
ExecutionEngine engine = new ExecutionEngine(graphDb, null);
ExecutionResult result = (ExecutionResult) engine.execute("START
n=node(*) MATCH n-[r]-m RETURN type(r), count(*) ORDER BY count(*) desc");
System.out.println(result);
}

finally {
((org.neo4j.graphdb.Transaction) tx).finish();
}
}
}

最佳答案

不要使用

import javax.transaction.Transaction;

但是使用

import org.neo4j.graphdb.Transaction;

这就是导致 ClassCastException 的原因。

关于java.lang.ClassCastException : org. neo4j.kernel.TopLevelTransaction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22554960/

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