CloseableDriver implements AutoCloseable { public Session newSession() { return driver.session(); } CloseableDriver(String uri, String user, String pwd); @Override void close(); Session newSession();  }
@Test public void queryTest() throws Exception { try (Session session = driver.newSession()) { StatementResult result = session.run("MATCH (loan:Loan)-[:APPLY]-(person:Person)-[:OWN]-(appPhone:Phone)-[:CALL]-(callPhones:Phone) " + "where loan.loanId='12345' " + "return distinct loan,person,appPhone,callPhones"); while (result.hasNext()) { Record record = result.next(); Node loan = record.get("loan").asNode(); Node person = record.get("person").asNode(); Node appPhone = record.get("appPhone").asNode(); Node callPhones = record.get("callPhones").asNode(); System.out.println(loan.get("amount").asDouble()); System.out.println(person.get("ssn").asString()); System.out.println(appPhone.get("phoneNo").asString()); System.out.println(callPhones.get("phoneNo").asString()); } } }