Java程序写neo4j写到一定数量就写不进去了
使用java api访问neo4j,总是写到一定数量就写不进去了,而且换了两个服务器上的两个neo4j数据库,都是写到这个数据量就写不进去了,是因为tcp连接数不够了嘛
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)));
}
}