The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.

Reactive SQL Clients

The Reactive SQL Clients have a straightforward API focusing on scalability and low-overhead. Currently, the following database servers are supported:

  • IBM Db2

  • PostgreSQL

  • MariaDB/MySQL

  • Microsoft SQL Server

  • Oracle

The Reactive SQL Client for Oracle is considered tech preview.

In tech preview mode, early feedback is requested to mature the idea. There is no guarantee of stability in the platform until the solution matures. Feedback is welcome on our mailing list or as issues in our GitHub issue tracker.

In this guide, you will learn how to implement a simple CRUD application exposing data stored in PostgreSQL over a RESTful API.

Extension and connection pool class names for each client can be found at the bottom of this document.
If you are not familiar with the Quarkus Vert.x extension, consider reading the Using Eclipse Vert.x guide first.

The application shall manage fruit entities:

public class Fruit {

    public Long id;

    public String name;

    public Fruit() {
    }

    public Fruit(String name) {
        this.name = name;
    }

    public Fruit(Long id, String name) {
        this.id = id;
        this.name = name;
    }
}

Do you need a ready-to-use PostgreSQL server to try out the examples?

docker run -it --rm=true --name quarkus_test -e POSTGRES_USER=quarkus_test -e POSTGRES_PASSWORD=quarkus_test -e POSTGRES_DB=quarkus_test -p 5432:5432 postgres:14.1

Installing

Reactive PostgreSQL Client extension

First, make sure your project has the quarkus-reactive-pg-client extension enabled. If you are creating a new project, use the following command:

CLI
quarkus create app org.acme:reactive-pg-client-quickstart \
    --extension=resteasy-reactive,reactive-pg-client \
    --no-code
cd reactive-pg-client-quickstart

创建Grade项目,请添加 --gradle 或者 --gradle-kotlin-dsl 参数。

关于如何安装并使用Quarkus CLI的更多信息,请参考Quarkus CLI指南

Maven
mvn io.quarkus.platform:quarkus-maven-plugin:2.11.2.Final:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=reactive-pg-client-quickstart \
    -Dextensions="resteasy-reactive,reactive-pg-client" \
    -DnoCode
cd reactive-pg-client-quickstart

创建Grade项目,请添加 -DbuildTool=gradle 或者 -DbuildTool=gradle-kotlin-dsl 参数。

If you have an already created project, the reactive-pg-client extension can be added to an existing Quarkus project with the add-extension command:

CLI
quarkus extension add 'reactive-pg-client'
Maven
./mvnw quarkus:add-extension -Dextensions="reactive-pg-client"
Gradle
./gradlew addExtension --extensions="reactive-pg-client"

Otherwise, you can manually add the dependency to your build file:

pom.xml
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-reactive-pg-client</artifactId>
</dependency>
build.gradle
implementation("io.quarkus:quarkus-reactive-pg-client")

Mutiny

RESTEasy Reactive includes supports for Mutiny types (e.g. Uni and Multi) out of the box.

In this guide, we will use the Mutiny API of the Reactive PostgreSQL Client. If you are not familiar with Mutiny, check Mutiny - an intuitive reactive programming library.

JSON Binding

We will expose Fruit instances over HTTP in the JSON format. Consequently, you also need to add the quarkus-resteasy-reactive-jackson extension:

CLI
quarkus extension add 'resteasy-jackson'
Maven
./mvnw quarkus:add-extension -Dextensions="resteasy-jackson"
Gradle
./gradlew addExtension --extensions="resteasy-jackson"

If you prefer not to use the command line, manually add the dependency to your build file:

pom.xml
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>
build.gradle
implementation("io.quarkus:quarkus-resteasy-reactive-jackson")

Of course, this is only a requirement for this guide, not any application using the Reactive PostgreSQL Client.

Configuring

The Reactive PostgreSQL Client can be configured with standard Quarkus datasource properties and a reactive URL:

src/main/resources/application.properties
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=quarkus_test
quarkus.datasource.password=quarkus_test
quarkus.datasource.reactive.url=postgresql://localhost:5432/quarkus_test

With that you may create your FruitResource skeleton and @Inject a io.vertx.mutiny.pgclient.PgPool instance:

src/main/java/org/acme/vertx/FruitResource.java
@Path("fruits")
public class FruitResource {

    @Inject
    io.vertx.mutiny.pgclient.PgPool client;
}

Database schema and seed data

Before we implement the REST endpoint and data management code, we need to set up the database schema. It would also be convenient to have some data inserted up-front.

For production, we would recommend to use something like the Flyway database migration tool. But for development we can simply drop and create the tables on startup, and then insert a few fruits.

src/main/java/org/acme/vertx/FruitResource.java
@Inject
@ConfigProperty(name = "myapp.schema.create", defaultValue = "true") (1)
boolean schemaCreate;

void config(@Observes StartupEvent ev) {
    if (schemaCreate) {
        initdb();
    }
}

private void initdb() {
    // TODO
}
You may override the default value of the myapp.schema.create property in the application.properties file.

Almost ready! To initialize the DB in development mode, we will use the client simple query method. It returns a Uni and thus can be composed to execute queries sequentially:

client.query("DROP TABLE IF EXISTS fruits").execute()
    .flatMap(r -> client.query("CREATE TABLE fruits (id SERIAL PRIMARY KEY, name TEXT NOT NULL)").execute())
    .flatMap(r -> client.query("INSERT INTO fruits (name) VALUES ('Orange')").execute())
    .flatMap(r -> client.query("INSERT INTO fruits (name) VALUES ('Pear')").execute())
    .flatMap(r -> client.query("INSERT INTO fruits (name) VALUES ('Apple')").execute())
    .await().indefinitely();
Wondering why we need block until the latest query is completed? This code is part of a @PostConstruct method and Quarkus invokes it synchronously. As a consequence, returning prematurely could lead to serving requests while the database is not ready yet.

That’s it! So far we have seen how to configure a pooled client and execute simple queries. We are now ready to develop the data management code and implement our RESTful endpoint.

Using

Query results traversal

In development mode, the database is set up with a few rows in the fruits table. To retrieve all the data, we will use the query method again:

Uni<RowSet<Row>> rowSet = client.query("SELECT id, name FROM fruits ORDER BY name ASC").execute();

When the operation completes, we will get a RowSet that has all the rows buffered in memory. A RowSet is an java.lang.Iterable<Row> and thus can be converted to a Multi:

Multi<Fruit> fruits = rowSet
  .onItem().transformToMulti(set -> Multi.createFrom().iterable(set))
  .onItem().transform(Fruit::from);

The Fruit#from method converts a Row instance to a Fruit instance. It is extracted as a convenience for the implementation of the other data management methods:

src/main/java/org/acme/vertx/Fruit.java
private static Fruit from(Row row) {
    return new Fruit(row.getLong("id"), row.getString("name"));
}

Putting it all together, the Fruit.findAll method looks like:

src/main/java/org/acme/vertx/Fruit.java
public static Multi<Fruit> findAll(PgPool client) {
    return client.query("SELECT id, name FROM fruits ORDER BY name ASC").execute()
            .onItem().transformToMulti(set -> Multi.createFrom().iterable(set))
            .onItem().transform(Fruit::from);
}

And the endpoint to get all fruits from the backend:

src/main/java/org/acme/vertx/FruitResource.java
@GET
public Multi<Fruit> get() {
    return Fruit.findAll(client);
}

Now start Quarkus in dev mode with:

CLI
quarkus dev
Maven
./mvnw quarkus:dev
Gradle
./gradlew --console=plain quarkusDev

Lastly, open your browser and navigate to http://localhost:8080/fruits, you should see:

[{"id":3,"name":"Apple"},{"id":1,"name":"Orange"},{"id":2,"name":"Pear"}]

Prepared queries

The Reactive PostgreSQL Client can also prepare queries and take parameters that are replaced in the SQL statement at execution time:

client.preparedQuery("SELECT id, name FROM fruits WHERE id = $1").execute(Tuple.of(id))
For PostgreSQL, the SQL string can refer to parameters by position, using $1, $2, …​etc. Please refer to the Database Clients details section for other databases.

Similar to the simple query method, preparedQuery returns an instance of PreparedQuery<RowSet<Row>>. Equipped with this tooling, we are able to safely use an id provided by the user to get the details of a particular fruit:

src/main/java/org/acme/vertx/Fruit.java
public static Uni<Fruit> findById(PgPool client, Long id) {
    return client.preparedQuery("SELECT id, name FROM fruits WHERE id = $1").execute(Tuple.of(id)) (1)
            .onItem().transform(RowSet::iterator) (2)
            .onItem().transform(iterator -> iterator.hasNext() ? from(iterator.next()) : null); (3)
}
1 Create a Tuple to hold the prepared query parameters.
2 Get an Iterator for the RowSet result.
3 Create a Fruit instance from the Row if an entity was found.

And in the JAX-RS resource:

src/main/java/org/acme/vertx/FruitResource.java
@GET
@Path("{id}")
public Uni<Response> getSingle(Long id) {
    return Fruit.findById(client, id)
            .onItem().transform(fruit -> fruit != null ? Response.ok(fruit) : Response.status(Status.NOT_FOUND)) (1)
            .onItem().transform(ResponseBuilder::build); (2)
}
1 Prepare a JAX-RS response with either the Fruit instance if found or the 404 status code.
2 Build and send the response.

The same logic applies when saving a Fruit:

src/main/java/org/acme/vertx/Fruit.java
public Uni<Long> save(PgPool client) {
    return client.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING id").execute(Tuple.of(name))
            .onItem().transform(pgRowSet -> pgRowSet.iterator().next().getLong("id"));
}

And in the web resource we handle the POST request:

src/main/java/org/acme/vertx/FruitResource.java
@POST
public Uni<Response> create(Fruit fruit) {
    return fruit.save(client)
            .onItem().transform(id -> URI.create("/fruits/" + id))
            .onItem().transform(uri -> Response.created(uri).build());
}

Result metadata

A RowSet does not only hold your data in memory, it also gives you some information about the data itself, such as:

  • the number of rows affected by the query (inserted/deleted/updated/retrieved depending on the query type),

  • the column names.

Let’s use this to support removal of fruits in the database:

src/main/java/org/acme/vertx/Fruit.java
public static Uni<Boolean> delete(PgPool client, Long id) {
    return client.preparedQuery("DELETE FROM fruits WHERE id = $1").execute(Tuple.of(id))
            .onItem().transform(pgRowSet -> pgRowSet.rowCount() == 1); (1)
}
1 Inspect metadata to determine if a fruit has been actually deleted.

And to handle the HTTP DELETE method in the web resource:

src/main/java/org/acme/vertx/FruitResource.java
@DELETE
@Path("{id}")
public Uni<Response> delete(Long id) {
    return Fruit.delete(client, id)
            .onItem().transform(deleted -> deleted ? Status.NO_CONTENT : Status.NOT_FOUND)
            .onItem().transform(status -> Response.status(status).build());
}

With GET, POST and DELETE methods implemented, we may now create a minimal web page to try the RESTful application out. We will use jQuery to simplify interactions with the backend:

<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Reactive PostgreSQL Client - Quarkus</title>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"
            integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
    <script type="application/javascript" src="fruits.js"></script>
</head>
<body>

<h1>Fruits API Testing</h1>

<h2>All fruits</h2>
<div id="all-fruits"></div>

<h2>Create Fruit</h2>
<input id="fruit-name" type="text">
<button id="create-fruit-button" type="button">Create</button>
<div id="create-fruit"></div>

</body>
</html>

In the Javascript code, we need a function to refresh the list of fruits when:

  • the page is loaded, or

  • a fruit is added, or

  • a fruit is deleted.

function refresh() {
    $.get('/fruits', function (fruits) {
        var list = '';
        (fruits || []).forEach(function (fruit) { (1)
            list = list
                + '<tr>'
                + '<td>' + fruit.id + '</td>'
                + '<td>' + fruit.name + '</td>'
                + '<td><a href="#" onclick="deleteFruit(' + fruit.id + ')">Delete</a></td>'
                + '</tr>'
        });
        if (list.length > 0) {
            list = ''
                + '<table><thead><th>Id</th><th>Name</th><th></th></thead>'
                + list
                + '</table>';
        } else {
            list = "No fruits in database"
        }
        $('#all-fruits').html(list);
    });
}

function deleteFruit(id) {
    $.ajax('/fruits/' + id, {method: 'DELETE'}).then(refresh);
}

$(document).ready(function () {

    $('#create-fruit-button').click(function () {
        var fruitName = $('#fruit-name').val();
        $.post({
            url: '/fruits',
            contentType: 'application/json',
            data: JSON.stringify({name: fruitName})
        }).then(refresh);
    });

    refresh();
});
1 The fruits parameter is not defined when the database is empty.

All done! Navigate to http://localhost:8080/fruits.html and read/create/delete some fruits.

Database Clients details

Database Extension name Pool class name Placeholders

IBM Db2

quarkus-reactive-db2-client

io.vertx.mutiny.db2client.DB2Pool

?

MariaDB/MySQL

quarkus-reactive-mysql-client

io.vertx.mutiny.mysqlclient.MySQLPool

?

Microsoft SQL Server

quarkus-reactive-mssql-client

io.vertx.mutiny.mssqlclient.MSSQLPool

@p1, @p2, etc.

Oracle

quarkus-reactive-oracle-client

io.vertx.mutiny.oracleclient.OraclePool

?

PostgreSQL

quarkus-reactive-pg-client

io.vertx.mutiny.pgclient.PgPool

$1, $2, etc.

Transactions

The reactive SQL clients support transactions. A transaction is started with io.vertx.mutiny.sqlclient.SqlConnection#begin and terminated with either io.vertx.mutiny.sqlclient.Transaction#commit or io.vertx.mutiny.sqlclient.Transaction#rollback. All these operations are asynchronous:

  • connection.begin() returns a Uni<Transaction>

  • transaction.commit() and transaction.rollback() return Uni<Void>

Managing transactions in the reactive programming world can be cumbersome. Instead of writing repetitive and complex (thus error-prone!) code, you can use the io.vertx.mutiny.sqlclient.Pool#withTransaction helper method.

The following snippet shows how to run 2 insertions in the same transaction:

public static Uni<Void> insertTwoFruits(PgPool client, Fruit fruit1, Fruit fruit2) {
    return client.withTransaction(conn -> {
        Uni<RowSet<Row>> insertOne = conn.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING id")
                .execute(Tuple.of(fruit1.name));
        Uni<RowSet<Row>> insertTwo = conn.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING id")
                .execute(Tuple.of(fruit2.name));

        return Uni.combine().all().unis(insertOne, insertTwo)
                // Ignore the results (the two ids)
                .discardItems();
    });
}

In this example, the transaction is automatically committed on success or rolled back on failure.

You can also create dependent actions as follows:

return client.withTransaction(conn -> conn

        .preparedQuery("INSERT INTO person (firstname,lastname) VALUES ($1,$2) RETURNING id")
        .execute(Tuple.of(person.getFirstName(), person.getLastName()))

        .onItem().transformToUni(id -> conn.preparedQuery("INSERT INTO addr (person_id,addrline1) VALUES ($1,$2)")
                .execute(Tuple.of(id.iterator().next().getLong("id"), person.getLastName())))

        .onItem().ignore().andContinueWithNull());

Working with batch query results

When executing batch queries, reactive SQL clients return a RowSet that corresponds to the results of the first element in the batch. To get the results of the following batch elements, you must invoke the RowSet#next method until it returns null.

Let’s say you want to update some rows and compute the total number of affected rows. You must inspect each RowSet:

PreparedQuery<RowSet<Row>> preparedQuery = client.preparedQuery("UPDATE fruits SET name = $1 WHERE id = $2");

Uni<RowSet<Row>> rowSet = preparedQuery.executeBatch(Arrays.asList(
        Tuple.of("Orange", 1),
        Tuple.of("Pear", 2),
        Tuple.of("Apple", 3)));

Uni<Integer> totalAffected = rowSet.onItem().transform(res -> {
    int total = 0;
    do {
        total += res.rowCount(); (1)
    } while ((res = res.next()) != null); (2)
    return total;
});
1 Compute the sum of RowSet#rowCount.
2 Invoke RowSet#next until it returns null.

As another example, if you want to load all the rows you just inserted, you must concatenate the contents of each RowSet:

PreparedQuery<RowSet<Row>> preparedQuery = client.preparedQuery("INSERT INTO fruits (name) VALUES ($1) RETURNING *");

Uni<RowSet<Row>> rowSet = preparedQuery.executeBatch(Arrays.asList(
        Tuple.of("Orange"),
        Tuple.of("Pear"),
        Tuple.of("Apple")));

// Generate a Multi of RowSet items
Multi<RowSet<Row>> rowSets = rowSet.onItem().transformToMulti(res -> {
    return Multi.createFrom().generator(() -> res, (rs, emitter) -> {
        RowSet<Row> next = null;
        if (rs != null) {
            emitter.emit(rs);
            next = rs.next();
        }
        if (next == null) {
            emitter.complete();
        }
        return next;
    });
});

// Transform each RowSet into Multi of Row items and Concatenate
Multi<Row> rows = rowSets.onItem().transformToMultiAndConcatenate(Multi.createFrom()::iterable);

Multiple Datasources

The reactive SQL clients support defining several datasources.

A typical configuration with several datasources would look like:

quarkus.datasource.db-kind=postgresql (1)
quarkus.datasource.username=user-default
quarkus.datasource.password=password-default
quarkus.datasource.reactive.url=postgresql://localhost:5432/default

quarkus.datasource."additional1".db-kind=postgresql (2)
quarkus.datasource."additional1".username=user-additional1
quarkus.datasource."additional1".password=password-additional1
quarkus.datasource."additional1".reactive.url=postgresql://localhost:5432/additional1

quarkus.datasource."additional2".db-kind=mysql (3)
quarkus.datasource."additional2".username=user-additional2
quarkus.datasource."additional2".password=password-additional2
quarkus.datasource."additional2".reactive.url=mysql://localhost:3306/additional2
1 The default datasource - using PostgreSQL.
2 A named datasource called additional1 - using PostgreSQL.
3 A named datasource called additional2 - using MySQL.

You can then inject the clients as follows:

@Inject (1)
PgPool defaultClient;

@Inject
@ReactiveDataSource("additional1") (2)
PgPool additional1Client;

@Inject
@ReactiveDataSource("additional2")
MySQLPool additional2Client;
1 Injecting the client for the default datasource does not require anything special.
2 For a named datasource, you use the @ReactiveDataSource CDI qualifier with the datasource name as its value.

UNIX Domain Socket connections

The PostgreSQL and MariaDB/MySQL clients can be configured to connect to the server through a UNIX domain socket.

First make sure that native transport support is enabled.

Then configure the database connection url. This step depends on the database type.

PostgreSQL

PostgreSQL domain socket paths have the following form: <directory>/.s.PGSQL.<port>

The database connection url must be configured so that:

  • the host is the directory in the socket path

  • the port is the port in the socket path

Consider the following socket path: /var/run/postgresql/.s.PGSQL.5432.

In application.properties add:

quarkus.datasource.reactive.url=postgresql://:5432/quarkus_test?host=/var/run/postgresql

MariaDB/MySQL

The database connection url must be configured so that the host is the socket path.

Consider the following socket path: /var/run/mysqld/mysqld.sock.

In application.properties add:

quarkus.datasource.reactive.url=mysql:///quarkus_test?host=/var/run/mysqld/mysqld.sock

Pooled Connection idle-timeout

Reactive datasources can be configured with an idle-timeout (in milliseconds). It is the maximum time a connection remains unused in the pool before it is closed.

The idle-timeout is disabled by default.

For example, you could expire idle connections after 60 minutes:

quarkus.datasource.reactive.idle-timeout=PT60M

配置参考

Common Datasource

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

类型

默认

The kind of database we will connect to (e.g. h2, postgresql…​).

Environment variable: QUARKUS_DATASOURCE_DB_KIND

string

If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present. When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_ENABLED

boolean

The container image name to use, for container based DevServices providers. If the provider is not container based (e.g. a H2 Database) then this has no effect.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_IMAGE_NAME

string

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_PORT

int

The container start command to use, for container based DevServices providers. If the provider is not container based (e.g. a H2 Database) then this has no effect.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_COMMAND

string

The name of the database to use if this Dev Service supports overriding it.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_DB_NAME

string

The username to use if this Dev Service supports overriding it.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_USERNAME

string

The password to use if this Dev Service supports overriding it.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_PASSWORD

string

Whether this particular data source should be excluded from the health check if the general health check for data sources is enabled. By default, the health check includes all configured data sources (if it is enabled).

Environment variable: QUARKUS_DATASOURCE_HEALTH_EXCLUDE

boolean

false

Whether or not an health check is published in case the smallrye-health extension is present. This is a global setting and is not specific to a datasource.

Environment variable: QUARKUS_DATASOURCE_HEALTH_ENABLED

boolean

true

Whether or not datasource metrics are published in case a metrics extension is present. This is a global setting and is not specific to a datasource. NOTE: This is different from the "jdbc.enable-metrics" property that needs to be set on the JDBC datasource level to enable collection of metrics for that datasource.

Environment variable: QUARKUS_DATASOURCE_METRICS_ENABLED

boolean

false

The datasource username

Environment variable: QUARKUS_DATASOURCE_USERNAME

string

The datasource password

Environment variable: QUARKUS_DATASOURCE_PASSWORD

string

The credentials provider name

Environment variable: QUARKUS_DATASOURCE_CREDENTIALS_PROVIDER

string

The credentials provider bean name. It is the &#64;Named value of the credentials provider bean. It is used to discriminate if multiple CredentialsProvider beans are available. For Vault it is: vault-credentials-provider. Not necessary if there is only one credentials provider available.

Environment variable: QUARKUS_DATASOURCE_CREDENTIALS_PROVIDER_NAME

string

Generic properties that are passed for additional container configuration. Properties defined here are database specific and are interpreted specifically in each database dev service implementation.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_CONTAINER_PROPERTIES

Map<String,String>

Generic properties that are added to the database connection URL.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_PROPERTIES

Map<String,String>

Additional named datasources

类型

默认

The kind of database we will connect to (e.g. h2, postgresql…​).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__DB_KIND

string

If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present. When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__DEVSERVICES_ENABLED

boolean

The container image name to use, for container based DevServices providers. If the provider is not container based (e.g. a H2 Database) then this has no effect.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__DEVSERVICES_IMAGE_NAME

string

Generic properties that are passed for additional container configuration. Properties defined here are database specific and are interpreted specifically in each database dev service implementation.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__DEVSERVICES_CONTAINER_PROPERTIES

Map<String,String>

Generic properties that are added to the database connection URL.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__DEVSERVICES_PROPERTIES

Map<String,String>

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__DEVSERVICES_PORT

int

The container start command to use, for container based DevServices providers. If the provider is not container based (e.g. a H2 Database) then this has no effect.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__DEVSERVICES_COMMAND

string

The name of the database to use if this Dev Service supports overriding it.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__DEVSERVICES_DB_NAME

string

The username to use if this Dev Service supports overriding it.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__DEVSERVICES_USERNAME

string

The password to use if this Dev Service supports overriding it.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__DEVSERVICES_PASSWORD

string

Whether this particular data source should be excluded from the health check if the general health check for data sources is enabled. By default, the health check includes all configured data sources (if it is enabled).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__HEALTH_EXCLUDE

boolean

false

The datasource username

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__USERNAME

string

The datasource password

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__PASSWORD

string

The credentials provider name

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__CREDENTIALS_PROVIDER

string

The credentials provider bean name. It is the &#64;Named value of the credentials provider bean. It is used to discriminate if multiple CredentialsProvider beans are available. For Vault it is: vault-credentials-provider. Not necessary if there is only one credentials provider available.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__CREDENTIALS_PROVIDER_NAME

string

Reactive Datasource

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

类型

默认

If we create a Reactive datasource for this datasource.

Environment variable: QUARKUS_DATASOURCE_REACTIVE

boolean

true

Whether prepared statements should be cached on the client side.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_CACHE_PREPARED_STATEMENTS

boolean

false

The datasource URL.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_URL

string

The datasource pool maximum size.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MAX_SIZE

int

When a new connection object is created, the pool assigns it an event loop. When #event-loop-size is set to a strictly positive value, the pool assigns as many event loops as specified, in a round-robin fashion. By default, the number of event loops configured or calculated by Quarkus is used. If #event-loop-size is set to zero or a negative value, the pool assigns the current event loop to the new connection.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_EVENT_LOOP_SIZE

int

Whether all server certificates should be trusted.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_ALL

boolean

false

PEM Trust config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_PEM

boolean

false

Comma-separated list of the trust certificate files (Pem format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_PEM_CERTS

list of string

JKS config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_JKS

boolean

false

Path of the key file (JKS format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_JKS_PATH

string

Password of the key file.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_JKS_PASSWORD

string

PFX config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_PFX

boolean

false

Path to the key file (PFX format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_PFX_PATH

string

Password of the key.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_PFX_PASSWORD

string

PEM Key/cert config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PEM

boolean

false

Comma-separated list of the path to the key files (Pem format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PEM_KEYS

list of string

Comma-separated list of the path to the certificate files (Pem format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PEM_CERTS

list of string

JKS config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_JKS

boolean

false

Path of the key file (JKS format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_JKS_PATH

string

Password of the key file.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_JKS_PASSWORD

string

PFX config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PFX

boolean

false

Path to the key file (PFX format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PFX_PATH

string

Password of the key.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PFX_PASSWORD

string

The number of reconnection attempts when a pooled connection cannot be established on first try.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_RECONNECT_ATTEMPTS

int

0

The interval between reconnection attempts when a pooled connection cannot be established on first try.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_RECONNECT_INTERVAL

Duration

PT1S

The hostname verification algorithm to use in case the server’s identity should be checked. Should be HTTPS, LDAPS or an empty string.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_HOSTNAME_VERIFICATION_ALGORITHM

string

The maximum time a connection remains unused in the pool before it is closed.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_IDLE_TIMEOUT

Duration

no timeout

Set to true to share the pool among datasources. There can be multiple shared pools distinguished by name, when no specific name is set, the __vertx.DEFAULT name is used.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_SHARED

boolean

false

Set the pool name, used when the pool is shared among datasources, otherwise ignored.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_NAME

string

Other unspecified properties to be passed through the Reactive SQL Client directly to the database when new connections are initiated.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_ADDITIONAL_PROPERTIES

Map<String,String>

Additional named datasources

类型

默认

If we create a Reactive datasource for this datasource.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE

boolean

true

Whether prepared statements should be cached on the client side.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_CACHE_PREPARED_STATEMENTS

boolean

false

The datasource URL.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_URL

string

The datasource pool maximum size.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_MAX_SIZE

int

When a new connection object is created, the pool assigns it an event loop. When #event-loop-size is set to a strictly positive value, the pool assigns as many event loops as specified, in a round-robin fashion. By default, the number of event loops configured or calculated by Quarkus is used. If #event-loop-size is set to zero or a negative value, the pool assigns the current event loop to the new connection.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_EVENT_LOOP_SIZE

int

Whether all server certificates should be trusted.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_ALL

boolean

false

PEM Trust config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_PEM

boolean

false

Comma-separated list of the trust certificate files (Pem format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_PEM_CERTS

list of string

JKS config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_JKS

boolean

false

Path of the key file (JKS format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_JKS_PATH

string

Password of the key file.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_JKS_PASSWORD

string

PFX config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_PFX

boolean

false

Path to the key file (PFX format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_PFX_PATH

string

Password of the key.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_PFX_PASSWORD

string

PEM Key/cert config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_PEM

boolean

false

Comma-separated list of the path to the key files (Pem format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_PEM_KEYS

list of string

Comma-separated list of the path to the certificate files (Pem format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_PEM_CERTS

list of string

JKS config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_JKS

boolean

false

Path of the key file (JKS format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_JKS_PATH

string

Password of the key file.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_JKS_PASSWORD

string

PFX config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_PFX

boolean

false

Path to the key file (PFX format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_PFX_PATH

string

Password of the key.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_PFX_PASSWORD

string

The number of reconnection attempts when a pooled connection cannot be established on first try.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_RECONNECT_ATTEMPTS

int

0

The interval between reconnection attempts when a pooled connection cannot be established on first try.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_RECONNECT_INTERVAL

Duration

PT1S

The hostname verification algorithm to use in case the server’s identity should be checked. Should be HTTPS, LDAPS or an empty string.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_HOSTNAME_VERIFICATION_ALGORITHM

string

The maximum time a connection remains unused in the pool before it is closed.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_IDLE_TIMEOUT

Duration

no timeout

Set to true to share the pool among datasources. There can be multiple shared pools distinguished by name, when no specific name is set, the __vertx.DEFAULT name is used.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_SHARED

boolean

false

Set the pool name, used when the pool is shared among datasources, otherwise ignored.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_NAME

string

Other unspecified properties to be passed through the Reactive SQL Client directly to the database when new connections are initiated.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_ADDITIONAL_PROPERTIES

Map<String,String>

About the Duration format

持续时间的格式使用标准的 java.time.Duration 格式您可以在 Duration#parse() javadoc 中了解更多信息。

您还可以提供以数字开头的持续时间值。 在这种情况下,如果该值仅包含一个数字,则转换器将该值视为秒。 否则,PT 会隐式添加到值的前面,以获得标准的 java.time.Duration 格式。

IBM Db2

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

类型

默认

Whether SSL/TLS is enabled.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_DB2_SSL

boolean

false

Additional named datasources

类型

默认

Whether SSL/TLS is enabled.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_DB2_SSL

boolean

false

MariaDB/MySQL

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

类型

默认

Charset for connections.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MYSQL_CHARSET

string

Collation for connections.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MYSQL_COLLATION

string

Desired security state of the connection to the server. See MySQL Reference Manual.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MYSQL_SSL_MODE

disabled, preferred, required, verify-ca, verify-identity

disabled

Additional named datasources

类型

默认

Charset for connections.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_MYSQL_CHARSET

string

Collation for connections.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_MYSQL_COLLATION

string

Desired security state of the connection to the server. See MySQL Reference Manual.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_MYSQL_SSL_MODE

disabled, preferred, required, verify-ca, verify-identity

disabled

Microsoft SQL Server

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

类型

默认

The desired size (in bytes) for TDS packets.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MSSQL_PACKET_SIZE

int

Whether SSL/TLS is enabled.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MSSQL_SSL

boolean

false

Additional named datasources

类型

默认

The desired size (in bytes) for TDS packets.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_MSSQL_PACKET_SIZE

int

Whether SSL/TLS is enabled.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_MSSQL_SSL

boolean

false

Oracle

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Additional named datasources

类型

默认

PostgreSQL

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

类型

默认

The maximum number of inflight database commands that can be pipelined.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_POSTGRESQL_PIPELINING_LIMIT

int

SSL operating mode of the client. See Protection Provided in Different Modes.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_POSTGRESQL_SSL_MODE

disable, allow, prefer, require, verify-ca, verify-full

disable

Additional named datasources

类型

默认

The maximum number of inflight database commands that can be pipelined.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_POSTGRESQL_PIPELINING_LIMIT

int

SSL operating mode of the client. See Protection Provided in Different Modes.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_POSTGRESQL_SSL_MODE

disable, allow, prefer, require, verify-ca, verify-full

disable