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()
}
请帮助我做错了什么,我已经检查了我的数据库位置,但与我在脚本和工具中使用的位置相同。
谢谢
您忘记了提交事务的 tx.close()
Sucess 只标记为成功
我在嵌入式模式下使用 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()
}
请帮助我做错了什么,我已经检查了我的数据库位置,但与我在脚本和工具中使用的位置相同。
谢谢
您忘记了提交事务的 tx.close()
Sucess 只标记为成功