2013-09-26 55 views
0

我的本地Neo4j的數據庫路徑是C:\的Neo4j-社區1.9.3_bup我的Java程序是越來越無法更新的Neo4j DB

我創建了一個簡單的java程序連接到Neo4j的數據庫,並插入一些節點。

但插入後,當我試圖通過Neo4jDataBrower回收這些節點,這些都沒有列出。

我用的是從Neo4j的門戶網站本身採取的代碼,

String DB_PATH = "C\\neo4j-community-1.9.3_bup"; 
    Map<String, String> config = new HashMap<String, String>(); 
    config.put("neostore.nodestore.db.mapped_memory", "10M"); 
    config.put("string_block_size", "60"); 
    config.put("array_block_size", "300"); 
    graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DB_PATH).setConfig(config).newGraphDatabase(); 
    registerShutdownHook(graphDb); 
    Transaction tx = graphDb.beginTx(); 
    try 
    { 
     firstNode = graphDb.createNode(); 
     firstNode.setProperty("message", "Hello, "); 
     secondNode = graphDb.createNode(); 
     secondNode.setProperty("message", "World!"); 
     relationship = firstNode.createRelationshipTo(secondNode, RelTypes.KNOWS); 
     relationship.setProperty("message", "brave Neo4j "); 
     tx.success(); 
    } 
    finally 
    { 
     tx.finish(); 
    } 

爲什麼它不工作?

請建議我..有一些問題vth路徑我給了或問題vth代碼?

沃納嗨,

的運行時異常是

Exception in thread "main" java.lang.RuntimeException: 
org.neo4j.kernel.lifecycle.LifecycleException: Component '[email protected]' was successfully initialized, but failed to start. Please see attached cause exception. 
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:280) 
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:106) 
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:88) 
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:207) 
    at com.Neo4J.src.EmbeddedNeo4j.createDb(EmbeddedNeo4j.java:54) 
    at com.Neo4J.src.EmbeddedNeo4j.main(EmbeddedNeo4j.java:38) 
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component '[email protected]' was successfully initialized, but failed to start. Please see attached cause exception. 
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497) 
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104) 
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:258) 
    ... 5 more 
Caused by: org.neo4j.kernel.StoreLockException: Could not create lock file 
    at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:74) 
    at org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:40) 
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491) 
    ... 7 more 

新的日誌,

Exception in thread "main" java.lang.RuntimeException: 

org.neo4j.kernel.lifecycle.LifecycleException: 

Component '[email protected]' was successfully initialized, but failed to start. Please see attached cause exception. 
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:280) 
    at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:106) 
    at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:88) 
    at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:207) 
    at com.Neo4J.src.EmbeddedNeo4j.createDb(EmbeddedNeo4j.java:57) 
    at com.Neo4J.src.EmbeddedNeo4j.main(EmbeddedNeo4j.java:41) 
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 
'[email protected]' was successfully initialized, but failed to start. Please see attached cause exception. 
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:497) 
    at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:104) 
    at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:258) 
    ... 5 more 
Caused by: org.neo4j.graphdb.TransactionFailureException: 
Unable to start TM, no active tx log file found but found either tm_tx_log.1 or tm_tx_log.2 file, please set one of them as active or remove them. 
    at org.neo4j.kernel.impl.transaction.TxManager.openLog(TxManager.java:750) 
    at org.neo4j.kernel.impl.transaction.TxManager.start(TxManager.java:138) 
    at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:491) 
    ... 7 more 

新的異常,

Sep 27, 2013 11:09:27 AM org.neo4j.server.logging.Logger log 
INFO: Starting Neo Server on port [7474] with [40] threads available 
2013-09-27 11:09:27.665:INFO::Logging to STDERR via org.mortbay.log.StdErrLog 
Sep 27, 2013 11:09:27 AM org.neo4j.server.logging.Logger log 
INFO: Using database at C:\neo4j-community-1.9.3_bup\data\graph.db 
Exception in thread "main" java.lang.NoSuchFieldError: remote_shell_enabled 
    at org.neo4j.server.database.Database.createDatabase(Database.java:77) 
    at org.neo4j.server.database.Database.<init>(Database.java:55) 
    at org.neo4j.server.NeoServerWithEmbeddedWebServer.startDatabase(NeoServerWithEmbeddedWebServer.java:179) 
    at org.neo4j.server.NeoServerWithEmbeddedWebServer.start(NeoServerWithEmbeddedWebServer.java:93) 
    at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:87) 
    at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:76) 
    at com.Neo4J.src.EmbeddedNeo4j.createDb(EmbeddedNeo4j.java:69) 
    at com.Neo4J.src.EmbeddedNeo4j.main(EmbeddedNeo4j.java:41) 

回答

0

C\\neo4j-community-1.9.3_bup是不是一個有效的路徑。它應該是C:\\neo4j-community-1.9.3_bup

但是,如果你指向你的Neo4J安裝目錄,而不是數據庫目錄本身,它可能是無效的。如果是這樣的話,路徑應該是C:\\neo4j-community-1.9.3_bup\data\graph.db

編輯:

,防止鎖的情況下,停止正在運行的Neo4j的實例,並擁有自己的Web控制檯啓動自己的數據庫,通過將這些線在那裏你初始化嵌入式數據庫的行之後:

Configurator configurator = new ServerConfigurator((GraphDatabaseAPI)graphDb); 
configurator.configuration().setProperty(Configurator.WEBSERVER_ADDRESS_PROPERTY_KEY, "127.0.0.1"); 
configurator.configuration().setProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, 7474); 

WrappingNeoServerBootstrapper bootstrapper = new WrappingNeoServerBootstrapper((GraphDatabaseAPI)graphDb, configurator); 
bootstrapper.start(); 
+0

嗨沃納,感謝您的回覆烏爾,我現在已經取代與C路徑:\\的Neo4j-社區1.9.3_bup \ DATA \ graph.db。但得到運行時異常,我已經添加上面相同.. – Sujana

+0

嗨,但在程序graphDb的類型GraphDatabaseService,但這裏constructer期待GraphDatabaseAPI。 – Sujana

+0

看到我更新的答案,我把'graphDb'投入'GraphDatabaseAPI' –