连接到java中的现有neo4j数据库

时间:2016-05-01 10:07:30

标签: java linux neo4j

我刚开始使用neo4j。当我想连接到Windows上的现有数据库时,一切正常,我的应用程序找到db并运行我的业务,​​但在Linux中我捕获Error starting org.neo4j.kernel.impl.factory.CommunityFacadeFactory, /opt/neo4j-community-3.0.0-M04/data/databases/graph.db异常。

我使用的是2.3.3版本

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j</artifactId>
    <version>2.3.3</version>
</dependency>

我的代码:

            GraphDatabaseService graphDb = null;
        try {
//            graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("/opt/neo4j-community-3.0.0-M04/data/databases/graph.db");
            graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(new File("/opt/neo4j-community-3.0.0-M04/data/databases/graph.db")).
            setConfig("org.neo4j.server.database.location", "/opt/neo4j-community-3.0.0-M04/data/databases/graph.db").
                    setConfig("allow_store_upgrade","true").
//            loadPropertiesFromFile("/opt/neo4j-community-3.0.0-M04/conf/neo4j.conf").
                    newGraphDatabase();
        } catch (Exception e) {
            System.out.println("e = " + e.getMessage());
            e.printStackTrace();
        }
        registerShutdownHook(graphDb);

如何连接到linux中的现有数据库。 谢谢。

添加stacktrace

e = Error starting org.neo4j.kernel.impl.factory.CommunityFacadeFactory, /opt/neo4j-community-3.0.0-M04/data/databases/graph.db
java.lang.RuntimeException: Error starting org.neo4j.kernel.impl.factory.CommunityFacadeFactory, /opt/neo4j-community-3.0.0-M04/data/databases/graph.db
    at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:143)
    at org.neo4j.kernel.impl.factory.CommunityFacadeFactory.newFacade(CommunityFacadeFactory.java:43)
    at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:108)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:129)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:117)
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:185)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:79)
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:74)
    at ir.isc.mot.BigDataWorkGroup.main(BigDataWorkGroup.java:28)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.NeoStoreDataSource@32b7faea' was successfully initialized, but failed to start. Please see attached cause exception.
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:462)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
    at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:112)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:111)
    at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:139)
    ... 8 more
Caused by: org.neo4j.kernel.impl.storemigration.UpgradeNotAllowedByConfigurationException: Failed to start Neo4j with an older data store version. To enable automatic upgrade, please set configuration parameter "allow_store_upgrade=true"
    at org.neo4j.kernel.impl.storemigration.ConfigMapUpgradeConfiguration.checkConfigurationAllowsAutomaticUpgrade(ConfigMapUpgradeConfiguration.java:39)
    at org.neo4j.kernel.impl.storemigration.StoreUpgrader.migrateIfNeeded(StoreUpgrader.java:135)
    at org.neo4j.kernel.NeoStoreDataSource.upgradeStore(NeoStoreDataSource.java:636)
    at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:527)
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:452)
    ... 13 more

0 个答案:

没有答案