我在 java 中创建了 Neo4j 节点和关系,它们的值来自 DB。当我试图在 Neoclipse 上显示它时,只显示前两个节点并显示它们的关系。代码:
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("D://ws-NEO//Fade");
Transaction tx=graphDb.beginTx();
Connection conn = null;
try{
conn=ConnectionFactory.getConnection();
Statement stat=conn.createStatement();
String sql="select * from Fade where App_Int_Id < 19"; //Two records are there in result
ResultSet rs=stat.executeQuery(sql);
String n1 = "",n2="",rel="",type="";
while(rs.next()){
n1=rs.getString(2);
n2=rs.getString(7);
rel=rs.getString(3);
type=rs.getString(4);
Node first=graphDb.createNode();
first.setProperty("name", n1);
Node second=graphDb.createNode();
second.setProperty("name", n2);
RelationshipType KNOWS = DynamicRelationshipType.withName(rel);
first.createRelationshipTo(second, KNOWS);
}
tx.success();}
finally
{ tx.finish();
graphDb.shutdown();
conn.close();
}
It outputs two records in console:
node1 -- My App
node2 -- GCAM
relationship -- Cash focus
Node1 ceated
Node2 ceated
relationship created
----------------------------------------------------------------------------------------------------
node1 -- My Test app
node2 -- GCAM
relationship -- Test Interface 11
Node1 ceated
Node2 ceated
relationship created
----------------------------------------------------------------------------------------------------
但是 Neoclipse 中只显示单个记录,其他记录丢失。请指导。