0

I am connecting my java application with neo4j DB using the neo4j-java-driver (bolt port). I want to run a load CSV query which should be run in a batch of 500, so I want to use periodic commit for the same. So first of all, I used :

USING PERIODIC COMMIT 500 ...

In this case, I got the error:

Caused by: org.neo4j.driver.exceptions.ClientException: Executing queries that use periodic commit in an open transaction is not possible.

I found some answers about it here saying that I should add :auto before the query, so I did that and got this error:

Caused by: org.neo4j.driver.exceptions.ClientException: Invalid input ':': expected <init> (line 1, column 1 (offset: 0))
:auto USING PERIODIC COMMIT 500
 ^
4

2 回答 2

1

https://neo4j.com/docs/driver-manual/1.7/sessions-transactions/

We need to use auto-commit transactions in this case. As the documents says:

Auto-commit transactions are the only way to execute USING PERIODIC COMMIT Cypher statements.

Example:

public void addPerson( String name )
{
    try ( Session session = driver.session() )
    {
        session.run( "CREATE (a:Person {name: $name})", parameters( "name", name ) );
    }
}
于 2021-02-17T04:06:13.607 回答
0

Faced the same, while working in python. You can use apoc's according based on your requirement

apoc.periodic.iterate('statement returning items', 'statement per item', {batchSize:1000,iterateList:true,parallel:false,params:{},concurrency:50,retries:0})

or

apoc.periodic.commit(statement,params)
于 2021-02-17T14:08:29.933 回答