简体   繁体   中英

Session with Value Null Java/Neo4J

Hello i´m having problems in Java Null Pointer Exception in Session

This is my code:

public Configs(String uri, String username, String password)
{

    Driver driver = GraphDatabase.driver(uri, AuthTokens.basic(username, password) );


}

.....

public Boolean existMachine(){

    machine mach  = new machine();


    try (Session session = driver.session())
    {

}
}

And i call the Function in main(String[] args) :

Configs connections = new Configs("bolt://localhost:7474", "neo4j", "");

if(connections.existMachine().booleanValue() == false)
{
...
}
else{
..
}

I´m getting error in:

try (Session session = driver.session())

You don't set drivers as an instance field of your class.

You have to make it available in existMachine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM