Java程序写neo4j写到一定数量就写不进去了
发布于 4 年前 作者 ningjingzhiyuan 583 次浏览 来自 问答

使用java api访问neo4j,总是写到一定数量就写不进去了,而且换了两个服务器上的两个neo4j数据库,都是写到这个数据量就写不进去了,是因为tcp连接数不够了嘛

微信截图_20210604211524.pngimage.png

2 回复

看报什么错

批量构建参考这种方式:

private void addPerson(String name) {
        // Sessions are lightweight and disposable connection wrappers.
        try (Session session = driver.session()) {
            // Wrapping a Cypher Query in a Managed Transaction provides atomicity
            // and makes handling errors much easier.
            // Use `session.writeTransaction` for writes and `session.readTransaction` for reading data.
            // These methods are also able to handle connection problems and transient errors using an automatic retry mechanism.
            session.writeTransaction(tx -> tx.run("MERGE (a:Person {name: $x})", parameters("x", name)));
        }
    }
回到顶部