Light
Dark
System
v4latest
v5dev
v4latest
v3
v2
v1

Java client library for EdgeDB

This is the official EdgeDB Java client, available to other JVM languages as well.

To get started, you will need to setup an EdgeDB project and have an instance created. For more information regarding how to do this, we recommend going through the Quickstart guide.

Once you have an instance running, you can add the driver dependency to your project.

Maven
Gradle
Copy
<dependency>
    <groupId>com.edgedb</groupId>
    <artifactId>driver</artifactId>
</dependency>
Copy
implementation 'com.edgedb:driver'

Once you have the dependency added, you can start using the client. The following is a simple example of how to connect to an EdgeDB instance and execute a query:

Futures
Reactor
Copy
import com.edgedb.driver.EdgeDBClient;
import java.util.concurrent.CompletableFuture;

public class Main {
    public static void main(String[] args) {
        var client = new EdgeDBClient();

        client.querySingle(String.class, "SELECT 'Hello, Java!'")
            .thenAccept(System.out::println)
            .toCompletableFuture().get();
    }
}
Copy
import com.edgedb.driver.EdgeDBClient;
import reactor.core.publisher.Mono;

public class Main {
    public static void main(String[] args) {
        var client = new EdgeDBClient();

        Mono.fromFuture(client.querySingle(String.class, "SELECT 'Hello, Java!'"))
            .doOnNext(System.out::println)
            .block();
    }
}

You can represent schema types with classes, reflecting the properties/links in the schema type:

Code
Schema 2.x
Schema 3+
Copy
@EdgeDBType
public class Person {
    public String name;
    public int age;
}

..

client.query(Person.class, "SELECT Person { name, age }")
    .thenAccept(result -> {
        for(var person : result) {
            System.out.println("Person { " + person.name + ", " + person.age + "}");
        }
    });
Copy
module default {
    type Person {
        property name -> str;
        property age -> int32;
    }
}
Copy
module default {
    type Person {
        name: str;
        age: int32;
    }
}

Learn more about data modeling.

The java binding uses the SLF4J logging facade. To enable logging, you will need to add a SLF4J implementation to your project, you can read more about that here.

Light
Dark
System

We use ChatGPT with additional context from our documentation to answer your questions. Not all answers will be accurate. Please join our Discord if you need more help.