Search
ctrl/
Ask AI
Light
Dark
System

Connection Parameters

The EdgeDBClient constructor can consume an EdgeDBConnection class containing connection arguments for the client.

Most of the time, the connection arguments are implicitly resolved via projects. In other cases, the EdgeDBConnection class exposes ways to construct connection arguments.

You can use a provided builder by calling the builder() method on EdgeDBConnection

Copy
var builder = EdgeDBConnection.builder();

The builder has the following methods:

Name

Type

Description

withUser

String

The username to connect as.

withPassword

String

The password used to authenticate.

withDatabase

String

The name of the database to use.

withHostname

String

The hostname of the database.

withPort

int

The port of the database.

withTlsca

String

The TLS certificate authority, used to verify the server certificate.

withTlsSecurity

TLSSecurityMode

The TLS security policy.

EdgeDBConnection also exposes static methods used to parse connection arguments from different sources.

This method parses a DSN string into an EdgeDBConnection.

Copy
var connection = EdgeDBConnection
    .fromDSN("edgedb://user:pass@host:port/db");

This method resolves connection arguments from an edgedb.toml project file.

Copy
var connection = EdgeDBConnection
    .fromProjectFile("~/myproject/edgedb.toml");

This method resolves the connection arguments for a given instance name.

Copy
var connection = EdgeDBConnection
    .fromInstanceName("my_instance_name");

This method is the default behaviour, it scans the current directory for a edgedb.toml project file, if none is found, the parent directory is scanned recursivly until a project file is found; if none is found, a FileNotFoundException is raised.

Copy
var connection = EdgeDBConnection
    .resolveEdgeDBTOML();

The parse method will resolve the given arguments as well as apply environment variables to the connection, following the priority levels of arguments.

Copy
var connection = EdgeDBConnection
    .parse("my_instance");