Hi,
I'm beginning in Neo4j java embedded graph.
I have made a first test but I cant visualize my graph in neo4j-community.
Here is my code for create the graph :
package connection;
import java.io.File;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
public class embededdedGraph {
public static void main(String... args) throws Exception {
GraphDatabaseFactory graphDbFactory = new GraphDatabaseFactory();
File graphDir = new File("/home/nicolas/neo4j-community-3.5.14/data/databases/cars.db");
GraphDatabaseService graphDb = graphDbFactory.newEmbeddedDatabase(graphDir);
Transaction tx = graphDb.beginTx();
createNode(graphDb);
tx.close();
}
public static void createNode(GraphDatabaseService graphDb) {
Node car = graphDb.createNode();
car.addLabel(Label.label("Car"));
car.setProperty("make", "tesla");
car.setProperty("model", "model3");
Node owner = graphDb.createNode(Label.label("Person"));
owner.setProperty("firstName", "Oliver");
owner.setProperty("lastName", "John");
owner.createRelationshipTo(car, RelationshipType.withName("owner"));
}
}
Next I change the value of "#dbms.active_database" to "dbms.active_database=cars.db.
When I restart neo4j-community the db name is "cars.db" but it's indicated there no labels and relationships in the database.
Thanks a lot,
Nicolas.