2

I am trying to use Neo4j embedded in Java applications, and I am using this code:

package com.tp.neo4j.java.examples;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
public class Neo4jJavaAPIDBOperation {
  public static void main(String[] args) {
    GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
    GraphDatabaseService db = dbFactory.newEmbeddedDatabase("C:/TPNeo4jDB");
    try (Transaction tx = db.beginTx()) {
        // Perform DB operations    
        tx.success();
    }   
 }
}

But I got this Exception:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    The method newEmbeddedDatabase(File) in the type GraphDatabaseFactory is not applicable for the arguments (String)
    Syntax error on token ";", try expected after this token

any idea, please

4

1 回答 1

2

newEmbeddedDatabase期望File作为论据

GraphDatabaseService db = dbFactory.newEmbeddedDatabase(new File("C:/TPNeo4jDB"));
于 2018-11-22T20:02:25.030 回答