Neo4j Getting Started Tutorial-(Install, configure)

Source: Internet
Author: User
Tags neo4j

Note: Find a lot of tutorials on the web, found that they are not suitable for 0 basic users, so they wrote a bit. The
1.x version is recommended, and the number of functions tested by 2.3.3 is abandoned. Install startup Download the tar package and go to the bin and run./neo4j open localhost:7474 in the URL to use the location setting of the configuration database.
Conf/neo4j-server.properties in line 14th org.neo4j.serve.database.location= modify using The Web visualization neo4j tool is WebAdmin, open with: Local/webadmin is opened in the URL, you can use the
Note: code to modify the database, it appears that each restart neo4j to be displayed in the WebAdmin, it is possible that data synchronization is slow Simple instance (Java Operation neo4j)

Package neo4j;
Import Java.io.File;

Import java.io.IOException;

Import javax.management.relation.Relation;
Import Org.neo4j.graphdb.GraphDatabaseService;
Import Org.neo4j.graphdb.Node;
Import org.neo4j.graphdb.Relationship;
Import Org.neo4j.graphdb.RelationshipType;
Import org.neo4j.graphdb.Transaction;
Import Org.neo4j.graphdb.factory.GraphDatabaseFactory;

Import Org.neo4j.io.fs.FileUtils; public class Test {public enum Reltypes implements relationshiptype{KNOWS} private static void R Egistershutdownhook (Final Graphdatabaseservice graphdb) {//registers a shutdown hook for the neo4j Instanc e so this it//shuts nicely when the VM exits (even if you "ctrl-c" the//running example before it ' s completed)/* To ensure the correct shutdown of the NEO4J database, we can add a close hook method * Registershutdownhook.
         The meaning of this method is to add a closed * hook to the JVM, and when the JVM shuts down, it executes all the hooks that have been set in the system via the method * Addshutdownhook, and the JVM shuts down when the system finishes executing the hooks. * So these hooks can be done when the JVM shuts downOperations such as memory cleanup, object destruction, and so on. */Runtime.getruntime (). Addshutdownhook (New Thread () {@Override public void run (
            ) {Graphdb.shutdown ();
    }
        } ); public static void Main (string[] args) throws IOException {fileutils.deleterecursively ("db")    
        );
        Graphdatabaseservice graphdb=new graphdatabasefactory (). Newembeddeddatabase ("db");
        Relationship relationship;
        Transaction Tx=graphdb.begintx ();
            try{Node Node1=graphdb.createnode ();

            Node Node2=graphdb.createnode ();
            Node1.setproperty ("message", "Hello");

            Node2.setproperty ("Message", "World");
            Relationship = Node1.createrelationshipto (Node2, reltypes.knows);


            Relationship.setproperty ("message", "brave neo4j");
            Tx.success ();
        System.out.println ("successfully");
        } finally{tx.finish ();} registershutdownhook (GRAPHDB); }

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.