如何将我的Neo4j嵌入式Db引用到getGraphDb()方法?

时间:2013-08-30 09:53:35

标签: java swing neo4j

我想开发一款软件,帮助用户在我的java应用程序中打开和关闭Neo4j嵌入式服务器。实际上,我单击按钮,应在默认Web浏览器中打开Web管理工具。但是,我被困了,因为我的行代码存在问题

InternalAbstractGraphDatabase graphdb = getGraphDb();

我不明白如何打开我在变量中实现的数据库:

 private static GraphDatabaseService BORO_DB;

并且有路径:

public static String DB_PATH;

代码下方:

final Variable var = new Variable(true);

InternalAbstractGraphDatabase graphdb = getGraphDb();
final WrappingNeoServerBootstrapper srv;
srv = new WrappingNeoServerBootstrapper( graphdb );

final JButton btnNewButton = new JButton("Show Graph - Start Server");
btnNewButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {

        if (var.getVar()){
            var.setVar(false);
            btnNewButton.setText("Graph - Stop Server");
            srv.start();

               try {

                 String url = "http://localhost:7474";
                 java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
               }
               catch (java.io.IOException e) {
                   System.out.println(e.getMessage());
               }

        }else{
            var.setVar(true);
            btnNewButton.setText("Show Graph - Start Server");
            srv.stop();
        }   
    }
});

您可以教我如何将我的数据库(BORO_DB)链接到getGraphDb()吗?

谢谢

1 个答案:

答案 0 :(得分:0)

使用DB_PATH,您可以像这样实例化BORO_DB:

BORO_DB = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);

srv=new WrappingNeoServerBootstrapper((GraphDatabaseAPI) BORO_DB);