cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Connecting to a specific graph

madiskou
Graph Buddy

Hello,

I have a multiple graph like below
2X_f_fe31d6386309b315d1a1e2318784157ca2b58e55.png

And i have a java application to communicate with the graph.
I want to know if i can specify the graph that i want to use or i have to use the default graph (because when i connect to the database with url: bolt://host:7687 i use the default graph).

Regards,
Mahdi.

1 ACCEPTED SOLUTION

Changing the database is done via the SessionConfig.
https://neo4j.com/docs/driver-manual/current/cypher-workflow/#database-selection

try ( Session session = driver.session( SessionConfig.forDatabase( "examples" ) ) ) {
...

or

SessionConfig sessionConfig = SessionConfig.builder()
        .withDatabase( "examples" )
        .withDefaultAccessMode( AccessMode.READ )
        .build();
try ( Session session = driver.session( sessionConfig ) ) {
...

View solution in original post

2 REPLIES 2

Changing the database is done via the SessionConfig.
https://neo4j.com/docs/driver-manual/current/cypher-workflow/#database-selection

try ( Session session = driver.session( SessionConfig.forDatabase( "examples" ) ) ) {
...

or

SessionConfig sessionConfig = SessionConfig.builder()
        .withDatabase( "examples" )
        .withDefaultAccessMode( AccessMode.READ )
        .build();
try ( Session session = driver.session( sessionConfig ) ) {
...

Thank you, it works with the SessionConfig.forDatabase()