cancel
Showing results for 
Search instead for 
Did you mean: 

Embedded in Java with GDS

depire
Node Clone

Dear friends,

I try to launch embedded database in Java using GDS. The execution of Main class gives me an error (There is no procedure with the name gds.list registered for this database instance).
I give you the files (pom.xml and the Main class).
I would like to know if it is possible to use GDS in embedded version.

Thanks.

I develop Maven project.

<dependencies>
	<dependency>
		<groupId>org.neo4j</groupId>
		<artifactId>neo4j-io</artifactId>
		<version>4.2.4</version>
	</dependency>
	<dependency>
		<groupId>org.neo4j</groupId>
		<artifactId>neo4j</artifactId>
		<version>4.2.4</version>
	</dependency>
	<dependency>
		<groupId>org.neo4j.driver</groupId>
		<artifactId>neo4j-java-driver</artifactId>
		<version>4.2.3</version>
	</dependency>
	<!-- pour gérer la base locale embedded database neo4j.Connection.java/Copy -->
	<dependency>
		<groupId>org.neo4j.test</groupId>
		<artifactId>neo4j-harness</artifactId>
		<version>4.2.4</version>
	</dependency>
	<dependency>
		<groupId>org.neo4j.gds</groupId>
		<artifactId>proc</artifactId>
		<version>1.5.1</version>
	</dependency>
	<dependency>
		<groupId>org.neo4j.gds</groupId>
		<artifactId>core</artifactId>
		<version>1.5.1</version>
	</dependency>
</dependencies>
<build>
	<plugins>
		<plugin>
			<groupId>org.openjfx</groupId>
			<artifactId>javafx-maven-plugin</artifactId>
			<version>0.0.3</version>
			<configuration>
				<mainClass>HelloFX</mainClass>
			</configuration>
		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<configuration>
				<source>1.8</source>
				<target>1.8</target>
				<encoding>UTF-8</encoding>
			</configuration>
		</plugin>
	</plugins>
</build>

with the following method.
public static void main(String args) {
System.out.println("Embedded");
String home = System.getProperty("user.home");
File databaseDirectory = new File(home+"/Downloads/NEO4J");
DatabaseManagementService managementService = new DatabaseManagementServiceBuilder( databaseDirectory.toPath() )
.build();

	GraphDatabaseService graphDb = managementService.database("neo4j");
	
	try ( Transaction tx = graphDb.beginTx() )
	{
		String command = "Call dbms.listConfig()";
		Result r = tx.execute(command);
		System.out.println("r: " + r.resultAsString());
		tx.commit();
		tx.close();

	}

	try ( Transaction tx = graphDb.beginTx() )
	{
		String command = "CALL gds.list()";
		Result r = tx.execute(command);
		System.out.println("r: " + r.resultAsString());
		tx.commit();
		tx.close();

	}
	
	registerShutdownHook( managementService );
}

private static void registerShutdownHook(DatabaseManagementService managementService) {
	// Registers a shutdown hook for the Neo4j instance so that it
    // shuts down nicely when the VM exits (even if you "Ctrl-C" the
    // running application).
    Runtime.getRuntime().addShutdownHook( new Thread()
    {
        @Override
        public void run()
        {
            managementService.shutdown();
        }
    } );
}
0 REPLIES 0