我在尝试使用neo4j bolt驱动程序运行简单的cypher时遇到错误。知道出了什么问题吗?
public void boltDriver() {
Config noSSL = Config.build()
.withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig();
Driver driver = GraphDatabase.driver("bolt://localhost:7474",
AuthTokens.basic("neo4j", "neo4j1"), noSSL); // <password>
try (Session session = driver.session()) {
StatementResult result;
String foafQuery = " MATCH (n) WHERE EXISTS(n.country) RETURN DISTINCT \"node\" as element, n.country AS country ";
result = session.run(foafQuery, parameters("name", "Joe"));
while (result.hasNext()) {
Record next = result.next();
System.out.println(next.get("element"));
System.out.println(next.get("country"));
}
}
}
例外: 线程“main”中的异常org.neo4j.driver.v1.exceptions.ClientException:协议错误,服务器建议的意外协议版本:1213486160 在org.neo4j.driver.internal.connector.socket.SocketClient.negotiateProtocol(SocketClient.java:198) 在org.neo4j.driver.internal.connector.socket.SocketClient.start(SocketClient.java:73) 在org.neo4j.driver.internal.connector.socket.SocketConnection。(SocketConnection.java:63) 在org.neo4j.driver.internal.connector.socket.SocketConnector.connect(SocketConnector.java:52) 在org.neo4j.driver.internal.pool.InternalConnectionPool $ 1.allocate(InternalConnectionPool.java:191) 在org.neo4j.driver.internal.pool.InternalConnectionPool $ 1.allocate(InternalConnectionPool.java:180) 在org.neo4j.driver.internal.pool.ThreadCachingPool.allocate(ThreadCachingPool.java:212) 在org.neo4j.driver.internal.pool.ThreadCachingPool.acquireFromGlobal(ThreadCachingPool.java:164) 在org.neo4j.driver.internal.pool.ThreadCachingPool.acquire(ThreadCachingPool.java:118) 在org.neo4j.driver.internal.pool.InternalConnectionPool.acquire(InternalConnectionPool.java:109) 在org.neo4j.driver.internal.InternalDriver.session(InternalDriver.java:53) 在Neo4jMain.boldDriver(Neo4jMain.java:55) 在Neo4jMain.main(Neo4jMain.java:30)
答案 0 :(得分:14)
您使用了错误的端口号。 7474默认用于http,而7687是二进制螺栓协议的默认值。
答案 1 :(得分:1)
一个重要的提示是1213486160是“HTTP”作为32位大端数字。