我需要一些帮助来修复此Java逻辑。请看一下Java代码,螺栓代码,当前输出和预期输出 Java代码:-
public void createRequestDB(final String message)
{
try(Session ses = driver.session())
{
String answer = ses.writeTransaction(new TransactionWork<String>()
{
@Override
public String execute(Transaction tx)
{
StatementResult result = tx.run(message);
return result.list().toString(); //Only if i use .list() i get the complete output from the Neo4j Database using Bolt Connection
}
});
System.out.println(answer);
Neo4j螺栓连接代码:-
String employee = "";
String user="";
user="MATCH(e:Employee) RETURN e.name AS name, e.department AS department, e.experience AS experience, e.level AS level\n";
try
{
MyAppCore ob = new MyAppCore("bolt://127.0.0.1:7687", "neo4j", "password");
ob.createRequestDB(user);
ob.close();
}
catch(Exception Ex)
{
System.out.println(Ex.getMessage());
}
employee +=user;
Eclipse控制台输出:-
[记录<{名称:“罗伯特”,部门:“心脏病专家”,经验:“ 6”, 级别:“ 4”}>,记录<{名称:“ John”,部门:“ Emergency_Doctor”, 经验:“ 8”,级别:“ 5”}>,记录<{名称:“鲍勃”,部门: “ Intensive_care_unit”,经验:“ 6”,级别:“ 3”}>,记录<{名称: “詹姆斯”,部门:“门诊病人”,经验:“ 5”,级别: “ 2”}>,记录<{name:“ Alice”,部门:“ Emergency”,经验: “ 8”,级别:“ 4”}>,记录<{名称:“ Michael”,部门:“ Pharmacy”, 经验:“ 5”,等级:“ 3”}>]
**预期的输出(稍后将保存到.txt文件中):-**
姓名:Robert部门:心脏病专家经验:6级:4
名称:约翰部门:急诊医生经验:8级:5
名称:Bob部门:Intensive_care_unit经验:6级:3
姓名:James部门:门诊病人经验:5级:2
名称:爱丽丝部门:紧急经历:8级:4
姓名:Michael部门:药学经验:5级:3