use neo4j java driver

107 views
Skip to first unread message

Afsane

unread,
Dec 12, 2016, 10:47:30 AM12/12/16
to Neo4j
Hello. I am new to neo4j. I want to use java-driver-1.0.6
I am added jar files to my java project and started neo4j 2.0.0. when I ran this code:

import org.neo4j.driver.v1.*;
public class Main {

    public static void main(String[] args) {
        Driver driver = GraphDatabase.driver( "bolt://localhost", AuthTokens.basic( "neo4j", "neo4j" )  );
        Session session = driver.session();

        session.run( "CREATE (a:Person {name:'Arthur', title:'King'})" );

        StatementResult result = session.run( "MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title" );
        while ( result.hasNext() )
        {
            Record record = result.next();
            System.out.println( record.get( "title" ).asString() + " " + record.get("name").asString() );
        }

        session.close();
        driver.close();
    }

}

I got this error:

Exception in thread "main" org.neo4j.driver.v1.exceptions.ClientException: Unable to connect to 'localhost' on port 7687, ensure the database is running and that there is a working network connection to it.
    at org.neo4j.driver.internal.connector.socket.SocketClient.start(SocketClient.java:82)
    at org.neo4j.driver.internal.connector.socket.SocketConnection.<init>(SocketConnection.java:64)
    at org.neo4j.driver.internal.connector.socket.SocketConnector.connect(SocketConnector.java:52)
    at org.neo4j.driver.internal.pool.InternalConnectionPool.acquire(InternalConnectionPool.java:113)
    at org.neo4j.driver.internal.InternalDriver.session(InternalDriver.java:53)
    at Main.main(Main.java:6)


Michael Hunger

unread,
Dec 12, 2016, 11:42:05 AM12/12/16
to ne...@googlegroups.com
The neo4j binary drivers only work with Neo4j from version 3.0

Michael

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Afsane Ebrahimian

unread,
Dec 12, 2016, 12:22:43 PM12/12/16
to ne...@googlegroups.com
thank you🙂
--
Afsane Ebrahimian
Student at Shiraz university

Reply all
Reply to author
Forward
0 new messages