java中创建的内嵌neo4j数据库,在javascript访问中数据不同步
发布于 6 年前 作者 chend 2247 次浏览 来自 问答

以下是java创建的neo4j链接,同时查询 if(graphDb==null){ graphDb = new GraphDatabaseFactory() .newEmbeddedDatabaseBuilder(new File(“neo4j/neo4jDatabase”)) .setConfig( bolt.type, “BOLT” ) .setConfig( bolt.enabled, “true” ) .setConfig( bolt.address, “localhost:7687” ) .setConfig(GraphDatabaseSettings.allow_upgrade,“true”) .newGraphDatabase(); } try(Transaction tx = graphDb.beginTx()) { org.neo4j.graphdb.Result result = graphDb.execute(“match ® where r.metaType=‘DIRECTORY’ or r.metaType=‘SECONDLEVEL’ return r”); 以下是javascript创建neo4j链接,同时查询: ajaxByNeo4j: function() { var driver = neo4j.v1.driver(“bolt://localhost:7687/neo4jDatabase/data”); var session = driver.session(); var tx = session.beginTransaction(); var success = false; tx .run(“match ® where r.metaType=‘DIRECTORY’ or r.metaType=‘SECONDLEVEL’ return r”) .then(function (result) { result.records.forEach(function (record) { vm.nodeses.push(record._fields[0].properties); }); console.log(vm.nodeses); vm.getHomeData(); success = true; // session.close(); }) .catch(function (error) { console.log(error); }); if (success) { tx.commit(); } else { //transaction is rolled black and nothing is created in the database console.log(‘rolled back’); tx.rollback(); } // driver.close(); }, 两者查处的数据不同,但是用的是一个库啊,这是什么原因,求大神解释,在这里跪谢!!!

2 回复

用 neo4j web控制台打开 java写入的数据有 吗? 还是考虑没有连接到同一个库上,你.newEmbeddedDatabaseBuilder(new File(“neo4j/neo4jDatabase”)) 这句应是在c:/user/用户名/下创建一个新库

neo4j嵌入式模式会锁定文件,用嵌入式模式以后,Server模式是无法使用的,你的 bolt://localhost:7687/neo4jDatabase/data 连的应该是另一个neo4j的库,两个不是一个库

回到顶部