在Web项目中使用Neo4j

时间:2013-05-10 23:30:39

标签: java neo4j

我有一个项目,我在mysql数据库中存放了30万个公司数据。我需要做的只是在neo4j中填写一些这些数据,以便以后公司可以设置一些关系。因此,公司将能够创建新的关系,但我必须创建节点并测试这些关系的一些查询(遍历)。所以,我的想法是这样的:

public class EnterCompaniesToNeo4j {


public static void main(String[] args)
{
    GraphDatabaseService graphDB = new GraphDatabaseFactory().newEmbeddedDatabase("build\\web\\NEO4J databases\\db1"); 
    Transaction tx = graphDB.beginTx();
    Node n = null;
    try
    {
        n = graphDB.createNode();
        n.setProperty( "taxnumber", "100000709" );
        System.out.println(n.getProperty("taxnumber"));
        tx.success();
    }
    catch ( Exception e )
    {
        tx.failure();
    }
    finally
    {
        tx.finish();
    }
    graphDB.shutdown();
    }
}

这是正确的做法吗? 我正在使用Netbeans和tomcat。

0 个答案:

没有答案