neo4j2.2 + jdk1.8 GraphDatabaseService.createNode()失败

时间:2016-06-07 10:59:17

标签: java neo4j

以下是测试代码:

   GraphDatabaseService graphDS;
   for (int i = 0; i < 50; i++) {
        Transaction tx = graphDS.beginTx();
        try {
            Node graphNode = graphDS.createNode();
            System.out.println("graphNode.ID:" + graphNode.getId());
            graphNode.addLabel(label("person"));
            tx.success();
        }catch (Exception e) {
            tx.failure();
            e.printStackTrace();
        }finally {
            tx.close();
        }
    }

它有时会成功,有时会失败,失败时,没有例外,它也会输出nodeId,但是数据库中没有创建节点。如果失败,它将无法在一个循环中创建50个节点。 这很奇怪,希望有人能告诉我原因,非常感谢!

0 个答案:

没有答案