螺栓连接关闭后连接到数据库

时间:2018-07-19 18:45:02

标签: java neo4j neo4j-browser

我制作了一个neo4j图形,可以在浏览器中看到它,我这样做是这样的:

Public class LookGraphNeo4j implements AutoCloseable{
    private Driver driver;
         public LookGraphNeo4j( String uri, String user, String password ){
                driver = GraphDatabase.driver( uri, AuthTokens.basic( user, password ) );
            }

         public void printGreeting( final String message){
                try ( Session session = driver.session() ){
                    String greeting = session.writeTransaction( new TransactionWork<String>(){
                        @Override
                        public String execute(org.neo4j.driver.v1.Transaction tx) {
                                StatementResult result = tx.run( message,
                                        parameters( "message", message ) );
                                return result.single().get( 0 ).asString();
                        }
                    } );
                    System.out.println( greeting );
                }
            }
            @Override
    public void close() throws Exception{
        driver.close();
    }
        public static void main(String [] args) {
    printGreeting(CREATE(holder1:Holder{AccountHolder:"0000",Class:"1111"}));
    }
}

代码运行完毕后,如何从数据库取回图形?

我尝试通过更改

删除所有内容
    public static void main(String [] args) {
printGreeting("CREATE(holder1:Holder{AccountHolder:"0000",Class:"1111"})");
}

进入:

    public static void main(String [] args) {
printGreeting("MATCH (n) DETACH DELETE n");
}

然后再次运行... 但是我只是碰到一个空指针异常。但是什么也没有发生……我也试图通过匹配holding1来获取holding并尝试获取它,但是说holding1不存在。任何帮助将不胜感激

0 个答案:

没有答案