Neo4j:Groovy脚本没有插入任何内容(Neo4j:Groovy script is not inserting anything)

编程入门 行业动态 更新时间:2024-10-16 16:45:20
Neo4j:Groovy脚本没有插入任何内容(Neo4j:Groovy script is not inserting anything)

我在嵌入模式下使用neo4j。 所以对于服务器上的数据库中的一些操作,我想要执行groovy脚本。 Groovy脚本运行成功没有任何错误,但是当我检查neo4j-communinty工具时它没有创建任何新记录。

脚本

/** * Created by prabjot on 7/1/17. */ @Grab(group="org.neo4j", module="neo4j-kernel", version="2.3.6") @Grab(group="org.neo4j", module="neo4j-lucene-index", version="2.3.6") @Grab(group='org.neo4j', module='neo4j-shell', version='2.3.6') @Grab(group='org.neo4j', module='neo4j-cypher', version='2.3.6') import org.neo4j.graphdb.factory.GraphDatabaseFactory import org.neo4j.graphdb.Node import org.neo4j.graphdb.Result import org.neo4j.graphdb.Transaction class Neo4jEmbeddedAccess { public static void main(String[] args) { def map=[:] map.put("allow_store_upgrade","true") map.put("remote_shell_enabled","true") def db = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("/opt/neo4j-community-3.0.4/data/databases/graph.db") .setConfig(map) .newGraphDatabase() Transaction tx =db.beginTx() Node person = db.createNode(); person.setProperty("name","prabjot") print("id---->" + person.id); Result result = db.execute("Match (country:Country) where id(country)=73 SET country.modified=true return country") print(result) tx.success(); println """starting embedded graph db use bin/neo4j-shell from a new distribution to connect we're keeping the graphdb open for 120 secs""" db.shutdown() }

请帮助我在这里做错了,我检查了我的数据库位置,但与我在脚本和工具中使用的相同。

谢谢

I am using neo4j in embedded mode. So for some operations in database on server, i am tying to execute groovy script. Groovy script is running successfully without any error,but it is not creating any new record when i am checking neo4j-communinty tool.

Script

/** * Created by prabjot on 7/1/17. */ @Grab(group="org.neo4j", module="neo4j-kernel", version="2.3.6") @Grab(group="org.neo4j", module="neo4j-lucene-index", version="2.3.6") @Grab(group='org.neo4j', module='neo4j-shell', version='2.3.6') @Grab(group='org.neo4j', module='neo4j-cypher', version='2.3.6') import org.neo4j.graphdb.factory.GraphDatabaseFactory import org.neo4j.graphdb.Node import org.neo4j.graphdb.Result import org.neo4j.graphdb.Transaction class Neo4jEmbeddedAccess { public static void main(String[] args) { def map=[:] map.put("allow_store_upgrade","true") map.put("remote_shell_enabled","true") def db = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("/opt/neo4j-community-3.0.4/data/databases/graph.db") .setConfig(map) .newGraphDatabase() Transaction tx =db.beginTx() Node person = db.createNode(); person.setProperty("name","prabjot") print("id---->" + person.id); Result result = db.execute("Match (country:Country) where id(country)=73 SET country.modified=true return country") print(result) tx.success(); println """starting embedded graph db use bin/neo4j-shell from a new distribution to connect we're keeping the graphdb open for 120 secs""" db.shutdown() }

Please help what i am doing wrong here, i have checked my db location but is same as i am using in script and tool.

Thanks

最满意答案

你忘了提交交易的tx.close()了

成功只标志着它成功

You forgot tx.close() which commits the Transaction

Sucess only marks it as successful

更多推荐

本文发布于:2023-07-22 09:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219114.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   内容   Groovy   Neo4j   script

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!