Neo4j java multiple session

467 views Asked by At

How can i create multiple session for neo4j in java using this driver org.neo4j.driver.v1?

I'm able to create a single session with this instruction:

Driver driver = GraphDatabase.driver( "bolt://localhost", +

AuthTokens.basic(neo4j, password), Config.build()
            .withEncryptionLevel( Config.EncryptionLevel.REQUIRED )
            .withTrustStrategy( Config.TrustStrategy.trustOnFirstUse( new File( "/path/to/neo4j_known_hosts" ) ) )
            .toConfig() );
1

There are 1 answers

0
Frank Pavageau On BEST ANSWER

In your code sample, you're not creating a Session, only a Driver.

The Session is created by calling driver.session(). If you want multiple sessions, you just call the method multiple times on the same Driver instance, e.g. if you're querying Neo4j while handling concurrent HTTP requests in your web application.