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

Quarkusでデータソースを設定

統一された設定モデルを使用して、Java Database Connectivity (JDBC) および Reactive ドライバのデータソースを定義します。

アプリケーションは、データソースを使用してリレーショナルデータベースにアクセスします。 Quarkusは、Java Database Connectivity(JDBC)およびReactiveデータベースドライバー用のデータソースを定義するための統一された設定モデルを提供します。

Quarkusは、 AgroalVert.x を使用して、JDBCとリアクティブドライバ用の高性能でスケーラブルなデータソース接続プーリングを提供します。 quarkus-jdbc-quarkus-reactive--client のエクステンションは、ビルド時最適化を提供し、設定されたデータソースを、セキュリティ、ヘルスチェック、メトリクスなどのQuarkusの機能と統合します。

リアクティブデータソースの消費と使用に関する詳細は、Quarkus Reactive SQLクライアントガイド を参照してください。

さらに、JDBCデータソースの消費と使用については、Quarkus Hibernate ORM ガイドを参照してください。

Quarkusでの datasources の設定入門

このセクションでは、基礎的な内容に慣れているユーザー向けに、データソースを素早くセットアップするための概要とコード・サンプルを提供します。

より高度な設定とその例については、 参照 を参照してください。

開発モードでのゼロコンフィグセットアップ

Quarkusでは、Dev Services機能によってデータベース設定が簡素化され、テストや開発(dev)モードでの実行のためのデータベース設定をゼロコンフィギュレーションで行うことができます。 開発モードでは、DevServicesを使用してQuarkusにデータベースを処理させる方法が推奨されます。一方、本番モードでは、Quarkusの外部で管理されるデータベースを指す明示的なデータベース設定の詳細を記述してください。

Dev Servicesを使用するには、 pom.xml ファイルに、希望するデータベースタイプに適したドライバエクステンション( jdbc-postgresql など)を追加します。 開発モードでは、明示的なデータベース接続の詳細を記述しない場合、Quarkusが自動的にデータベースのセットアップを行い、アプリケーションとデータベース間の接続を行います。

ユーザークレデンシャルを指定すると、基礎となるデータベースはそのクレデンシャルを使用するように設定されます。 これは、外部ツールでデータベースに接続したい場合に便利です。

この機能を使用するには、データベースの種類に応じて、DockerまたはPodmanコンテナランタイムがインストールされているようにして下さい。H2などの一部のデータベースはインメモリモードで動作するため、コンテナランタイムは必要ありません。

prodモードの実際の接続詳細の前に %prod. を付けて、それらがdev モードで適用されないようにします。 詳細については、"設定リファレンス" ガイドの Profiles セクションを参照してください。

Dev Services の詳細については、 Dev Services の概要 を参照してください。

詳細およびオプション設定については、 Dev Services for databases を参照してください。

JDBC データソースの設定

  1. 選択したデータベースの正しい JDBC エクステンションを追加します。

    • quarkus-jdbc-db2

    • quarkus-jdbc-derby

    • quarkus-jdbc-h2

    • quarkus-jdbc-mariadb

    • quarkus-jdbc-mssql

    • quarkus-jdbc-mysql

    • quarkus-jdbc-oracle

    • quarkus-jdbc-postgresql

  2. JDBC データソースを設定します:

    quarkus.datasource.db-kind=postgresql (1)
    quarkus.datasource.username=<your username>
    quarkus.datasource.password=<your password>
    
    quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/hibernate_orm_test
    quarkus.datasource.jdbc.max-size=16
    1 この設定値は、クラスパスに複数のデータベース・エクステンションがある場合にのみ必要です。

使用可能なエクステンションが1つしかない場合、Quarkusはこれを正しいエクステンションとみなします。テストスコープにドライバーを追加すると、Quarkusは自動的に指定したドライバーをテストに含めます。

JDBC接続プールのサイズ調整

負荷のピーク時の過負荷からデータベースを保護するには、データベースの負荷を軽減するためにプールのサイズを適切に設定します。 最適なプールのサイズは、並列アプ リ ケーシ ョ ンのユーザー数や作業負荷の性質な ど、 さ ま ざ ま な要因に よ っ て異な り ます。

プールサイズを小さく設定しすぎると、接続待ちの間にタイムアウトする リクエストが出てくるかもしれないことに注意してください。

プールサイズ調整プロパティの詳細については、 JDBC 設定リファレンス のセクションを参照してください。

Reactiveデータソースの設定

  1. 選択したデータベースの正しいリアクティブエクステンションを追加します。

    • quarkus-reactive-db2-client

    • quarkus-reactive-mssql-client

    • quarkus-reactive-mysql-client

    • quarkus-reactive-oracle-client

    • quarkus-reactive-pg-client

  2. リアクティブデータソースを設定します:

    quarkus.datasource.db-kind=postgresql (1)
    quarkus.datasource.username=<your username>
    quarkus.datasource.password=<your password>
    
    quarkus.datasource.reactive.url=postgresql:///your_database
    quarkus.datasource.reactive.max-size=20
    1 この設定値は、クラスパスに複数の Reactive ドライバー・エクステンションがある場合にのみ必要です。

データソースの設定

以下のセクションでは、単一または複数のデータソースの設定について説明します。 ここでは簡単のため、単一のデータソースをデフォルトの (無名の) データソースとして参照します。

単一のデータソースの設定

データソースには、JDBC データソース、リアクティブ、またはその両方を指定できます。 これは、設定とプロジェクトエクステンションの選択に依存します。

  1. 以下の設定プロパティでデータソースを定義します。 db-kind は、どのデータベースプラットフォームに接続するかを定義します。例えば、 h2 の場合:

    quarkus.datasource.db-kind=h2

    Quarkusは、 db-kind データベースプラットフォーム属性の指定値から、使用するJDBCドライバクラスを推測します。

    この手順は、アプリケーションが複数のデータベース・ドライバに依存している場合にのみ必要です。 アプリケーションが単一のドライバで動作する場合、このドライバは自動的に検出されます。

    Quarkusには現在、以下のデータベースのdb-kindが組み込まれています:

    • DB2: db2

    • Derby: derby

    • H2: h2

    • MariaDB: mariadb

    • Microsoft SQL Server: mssql

    • MySQL: mysql

    • Oracle: oracle

    • PostgreSQL: postgresqlpgsql、または pg

    • ビルトインされていない種類のデータベースを使用するには、 other を使用し、JDBC ドライバを明示的に定義します。

      他のデータベースの使用 で説明するように、QuarkusアプリでJVMモードの任意のJDBCドライバを使用できます。 ただし、組込ではない種類のデータベースを使用すると、アプリケーションをネイティブ実行ファイルにコンパイルするときにうまくいかない可能性があります。

      ネイティブ実行可能ファイルをビルドする場合は、利用可能なJDBC Quarkusエクステンションを使用するか、特定のドライバ用にカスタムエクステンションを作成することをお勧めします。

  2. 以下のプロパティを設定し、クレデンシャルを定義します:

    quarkus.datasource.username=<your username>
    quarkus.datasource.password=<your password>

    また、データソースに クレデンシャルプロバイダを使用することで、Vault からパスワードを取得することもできます。

これまでは、JDBC ドライバとReactiveドライバのどちらを使用していても、設定は同じでした。データベースの種類とクレデンシャルを定義したら、あとは使用するドライバの種類に依存します。JDBC とReactive・ドライバを同時に使用することは可能です。

JDBC データソース

JDBC は最も一般的なデータベース接続パターンで、典型的には非リアクティブ型の Hibernate ORM と組み合わせて使用する場合に必要となります。

  1. JDBC データソースを使用するには、必要な依存関係を追加することから始めます:

    1. 組み込みのJDBCドライバで使用する場合は、以下のリストからリレーショナルデータベースドライバ用のQuarkusエクステンションを選択して追加します:

      • Derby - quarkus-jdbc-derby

      • H2 - quarkus-jdbc-h2

        H2およびDerbyデータベースは、"組み込みモード "で実行するように設定することができます。しかし、Derbyエクステンションは、組み込みデータベースエンジンをネイティブ実行可能ファイルにコンパイルすることをサポートしていません。

        結合テストに関する提案については、 インメモリデータベースを使ったテスト をお読みください。

      • DB2 - quarkus-jdbc-db2

      • MariaDB - quarkus-jdbc-mariadb

      • Microsoft SQL Server - quarkus-jdbc-mssql

      • MySQL - quarkus-jdbc-mysql

      • Oracle - quarkus-jdbc-oracle

      • PostgreSQL - quarkus-jdbc-postgresql

      • その他のJDBCエクステンション、 SQLite や、その ドキュメント などは Quarkiverse にあります。

        例えば、PostgreSQLドライバー依存関係を追加します:

        ./mvnw quarkus:add-extension -Dextensions="jdbc-postgresql"

        組込JDBC ドライバのエクステンションを使用すると、カスタムと組込JDBC ドライバーに適用可能な JDBC 接続プールの実装である Agroal エクステンションが自動的に含まれます。 しかし、カスタムドライバーの場合、Agroal を明示的に追加する必要があります。

    2. カスタム JDBC ドライバーと共に使用する場合は、リレーショナルデータベースドライバのエクステンションと一緒に、 quarkus-agroal 依存関係をプロジェクトに追加します:

      ./mvnw quarkus:add-extension -Dextensions="agroal"

      別のデータベース用の JDBC ドライバーを使用するには、 組込エクステンションのないデータベースか、別のドライバー を使用してください。

  2. JDBC URL プロパティを定義して、JDBC 接続を構成します:

    quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/hibernate_orm_test

    プロパティ名の接頭辞 jdbc に注意してください。JDBC 固有の設定プロパティにはすべて、接頭語に jdbc が付きます。Reactiveデータソースの場合、接頭辞は reactive です。

JDBCの設定の詳細については、 JDBC URLフォーマットリファレンス および Quarkusエクステンションとデータベースドライバリファレンス を参照してください。

カスタムデータベースとドライバー

QuarkusがJDBCドライバーでエクステンションを提供していないデータベースに接続する必要がある場合、代わりにカスタムドライバーを使用できます。 たとえば、プロジェクトでOpenTracing JDBCドライバを使用している場合です。

エクステンションがない場合、ドライバはJVMモードで実行されているQuarkusアプリで正しく動作します。 しかし、アプリケーションをネイティブ実行可能ファイルにコンパイルする場合、ドライバが動作する可能性は低くなります。 ネイティブ実行可能ファイルを作成する場合は、既存のJDBC Quarkusエクステンションを使用するか、ドライバ用にエクステンションを作成してください。

OpenTracing は非推奨となり、OpenTelemetry が選ばれました。トレース情報については、 データソースのトレース の関連セクションを参照してください。

レガシー OpenTracing ドライバーを使用したカスタムドライバ定義の例:
quarkus.datasource.jdbc.driver=io.opentracing.contrib.jdbc.TracingDriver
JVMモードで、組込サポートのないデータベースへのアクセスを定義する例:
quarkus.datasource.db-kind=other
quarkus.datasource.jdbc.driver=oracle.jdbc.driver.OracleDriver
quarkus.datasource.jdbc.url=jdbc:oracle:thin:@192.168.1.12:1521/ORCL_SVC
quarkus.datasource.username=scott
quarkus.datasource.password=tiger

JDBC設定オプションや、接続プール・サイズなどの他の側面の設定に関するすべての詳細については、 JDBC構成リファレンス セクションを参照してください。

データソースの消費

Hibernate ORMを使用する場合、Hibernateレイヤーは自動的にデータソースを選択し、それを使用します。

データソースへのコード内アクセスは、他のBeanと同様に以下のように取得します:

@Inject
AgroalDataSource defaultDataSource;

上記の例では、型は javax.sql.DataSource のサブタイプである AgroalDataSource です。 このため、 javax.sql.DataSource を注入される型として使用することもできます。

リアクティブデータソース

Quarkusには、リアクティブデータソースで使用できるリアクティブクライアントがいくつかあります。

  1. 対応するエクステンションをアプリケーションに追加します:

    • DB2: quarkus-reactive-db2-client

    • MariaDB/MySQL: quarkus-reactive-mysql-client

    • Microsoft SQL Server: quarkus-reactive-mssql-client

    • Oracle: quarkus-reactive-oracle-client

    • PostgreSQL: quarkus-reactive-pg-client

      インストールされているエクステンションは、データソースの設定で定義する quarkus.datasource.db-kind と一致している必要があります。

  2. ドライバを追加したら、接続URLを設定し、接続プールの適切なサイズを定義します。

    quarkus.datasource.reactive.url=postgresql:///your_database
    quarkus.datasource.reactive.max-size=20
リアクティブ接続プールのサイズ調整

負荷のピーク時の過負荷からデータベースを保護するには、データベースの負荷を軽減するためにプールのサイズを適切に設定します。 適切なサ イ ズは常に、 並列アプ リ ケーシ ョ ンのユーザー数や作業負荷の性質な ど、 さ ま ざ ま な要因に よ っ て異な り ます。

プールサイズを小さく設定しすぎると、接続待ちの間にタイムアウトする リクエストが出てくるかもしれないことに注意してください。

プールサイズ調整プロパティの詳細については、 Reactive データソース設定リファレンス のセクションを参照してください。

JDBC とリアクティブデータソースの同時利用

指定された種類のデータベースを扱うJDBC エクステンション(およびAgroal)、そしてリアクティブデータソースエクステンションが含まれる場合、それらはデフォルトで作成されます。

  • JDBC データソースを明示的に無効にするには、次のようにします:

    quarkus.datasource.jdbc=false
  • リアクティブデータソースを明示的に無効にするには、次のようにします:

    quarkus.datasource.reactive=false

    ほとんどの場合、JDBC ドライバまたはリアクティブ・データソース・エクステンションのどちらかが存在し、両方は存在しないため、上記の構成はオプションになります。

複数のデータソースの設定

Hibernate ORM エクステンションは、設定プロパティを使用した 永続化ユニット の定義をサポートしています。 各固有化ユニットに対して、任意のデータソースを指定します。

複数のデータソースの定義は、単一のデータソースを定義するのと同じように機能しますが、重要な変更点が 1 つあります。それは、各データソースの名前 (設定プロパティ) を指定する必要があることです。

以下の例では、3つの異なるデータソースを提供しています:

  • デフォルトのデータソース

  • users という名前のデータソース

  • inventory という名前のデータソース

Each with its configuration:

quarkus.datasource.db-kind=h2
quarkus.datasource.username=username-default
quarkus.datasource.jdbc.url=jdbc:h2:mem:default
quarkus.datasource.jdbc.max-size=13

quarkus.datasource.users.db-kind=h2
quarkus.datasource.users.username=username1
quarkus.datasource.users.jdbc.url=jdbc:h2:mem:users
quarkus.datasource.users.jdbc.max-size=11

quarkus.datasource.inventory.db-kind=h2
quarkus.datasource.inventory.username=username2
quarkus.datasource.inventory.jdbc.url=jdbc:h2:mem:inventory
quarkus.datasource.inventory.jdbc.max-size=12

設定プロパティに余分なセクションがあることに注意してください。 構文は次の通りです: quarkus.datasource.[optional name.][datasource property] .

データベースエクステンションが1つしかインストールされていない場合でも、名前付きデータベースをQuarkusで検出できるように、少なくとも1つのビルド時プロパティを指定する必要があります。 一般的に、これは db-kind プロパティですが、 Dev Services for Databases のガイドに従って、名前付きデータソースを作成するためにDev Servicesプロパティを指定することもできます。

名前付きデータソース注入

複数のデータソースを使用する場合は、各 DataSource にデータソース名を値として指定した io.quarkus.agroal.DataSource 修飾子を付与してください。

前のセクションで述べたプロパティを使用して3つの異なるデータソースを設定し、それぞれのデータソースに以下のように注入します:

@Inject
AgroalDataSource defaultDataSource;

@Inject
@DataSource("users")
AgroalDataSource usersDataSource;

@Inject
@DataSource("inventory")
AgroalDataSource inventoryDataSource;

データソースの有効化/無効化

データソースがビルド時に設定されている場合、 デフォルトでは実行時にアクティブになります。 つまり、Quarkusはアプリケーションの起動時に対応するJDBC接続プールまたはリアクティブクライアントを開始します。

実行時にデータソースを非アクティブにするには、 quarkus.datasource[.optional name].activefalse に設定します。 その場合、Quarkusはアプリケーション起動時に対応するJDBC接続プールまたはリアクティブクライアントを起動しません。 実行時に対応するデータソースを使用しようとすると、明確なエラーメッセージとともに失敗します。

これは特に、アプリケーションの実行時に、あらかじめ決められたデータソースのうちの1つを使用できるようにしたい場合に便利です。

他のQuarkusエクステンションが非アクティブなデータソースに依存している場合、 そのエクステンションの起動に失敗することがあります。

その場合、他のエクステンションも無効にする必要があります。 たとえば、 Hibernate ORM については、こちらを 参照してください。

例えば、次のような設定です:

quarkus.datasource."pg".db-kind=postgres
quarkus.datasource."pg".active=false
quarkus.datasource."pg".jdbc.url=jdbc:postgresql:///your_database

quarkus.datasource."oracle".db-kind=oracle
quarkus.datasource."oracle".active=false
quarkus.datasource."oracle".jdbc.url=jdbc:oracle:///your_database

実行時に quarkus.datasource."pg".active=true を設定すると PostgreSQLデータソースだけが利用可能になり、 実行時に quarkus.datasource."oracle".active=true を設定すると Oracleデータソースだけが利用可能になります。

Custom configuration profiles can help simplify such a setup. By appending the following profile-specific configuration to the one above, you can select a persistence unit/datasource at runtime simply by setting quarkus.profile: quarkus.profile=prod,pg or quarkus.profile=prod,oracle.

%pg.quarkus.hibernate-orm."pg".active=true
%pg.quarkus.datasource."pg".active=true
# Add any pg-related runtime configuration here, prefixed with "%pg."

%oracle.quarkus.hibernate-orm."oracle".active=true
%oracle.quarkus.datasource."oracle".active=true
# Add any pg-related runtime configuration here, prefixed with "%pg."

It can also be useful to define a CDI bean producer redirecting to the currently active datasource, like this:

public class MyProducer {
    @Inject
    DataSourceSupport dataSourceSupport;

    @Inject
    @DataSource("pg")
    AgroalDataSource pgDataSourceBean;

    @Inject
    @DataSource("oracle")
    AgroalDataSource oracleDataSourceBean;

    @Produces
    @ApplicationScoped
    public AgroalDataSource dataSource() {
        if (dataSourceSupport.getInactiveNames().contains("pg")) {
            return oracleDataSourceBean;
        } else {
            return pgDataSourceBean;
        }
    }
}

データソースの統合

データソースのヘルスチェック

quarkus-smallrye-health エクステンションを使用する場合、 quarkus-agroal およびリアクティブクライアントエクステンションは、 データソースを検証するためのreadiness ヘルスチェックを自動的に追加します。

アプリケーションのヘルスチェックエンドポイント /q/health/ready (デフォルト) にアクセスすると、データソースの検証状況に関する情報を受け取ります。 複数のデータソースがある場合は、すべてのデータソースがチェックされ、データソースの検証に失敗した場合は、ステータスが DOWN に変わります。

この動作を無効にするには、 quarkus.datasource.health.enabled プロパティを使用します。

特定のデータソースだけをヘルスチェックから除外するには、次のようにします:

quarkus.datasource."datasource-name".health-exclude=true

データソースのメトリクス

quarkus-micrometer または quarkus-smallrye-metrics エクステンションを使用している場合、 quarkus-agroal は、データソース関連のメトリックをメトリック・レジストリに貢献することができます。これは、 quarkus.datasource.metrics.enabled プロパティを true に設定することで有効になります。

公開されたメトリクスが実際の値を含むためには、Agroal メカニズムによって内部的にメトリクス収集が有効になっている必要があります。 デフォルトでは、メトリクス・エクステンションが存在し、Agroal エクステンションのメトリクスが有効になっている場合、このメトリクス収集メカニズムはすべてのデータソースに対して有効になります。

特定のデータ・ソースのメトリクスを無効にするには、 quarkus.datasource.jdbc.enable-metricsfalse に設定するか、指定したデータ・ソースに対して quarkus.datasource.<datasource name>.jdbc.enable-metrics を適用します。 これにより、メトリクスを収集するメカニズムが無効になっている場合は、メトリクスの収集と /q/metrics エンドポイントでの公開が無効になります。

逆に、名前付きデータソースに対して quarkus.datasource.jdbc.enable-metricstrue 、または quarkus.datasource.<datasource name>.jdbc.enable-metrics に設定すると、メトリッ ク・エクステンションが使用されていなくても、明示的にメトリクスの収集が可能になります。 これは、収集されたメトリクスにプログラムでアクセスする必要がある場合に便利です。 これらは、注入された AgroalDataSource インスタンスで dataSource.getMetrics() を呼び出した後に使用できます。

このデータ・ソースのメトリクス収集が無効な場合は、すべての値がゼロになります。

データソースのトレース

データソースでトレースを使用するには、プロジェクトに quarkus-opentelemetry エクステンションを追加する必要があります。

トレースが必要だからといって、別のドライバを宣言する必要はありません。JDBC ドライバーを使用する場合は、 こちら のOpenTelemetry エクステンションの説明書に従う必要があります。

すべてのトレース基盤が整っていても、データソースのトレースはデフォルトでは有効になっていないので、このプロパティを設定して有効にする必要があります:

# enable tracing
quarkus.datasource.jdbc.telemetry=true

Narayanaトランザクションマネージャの統合

Narayana JTAエクステンションも利用可能であれば、統合は自動的に行われます。

transactions 設定プロパティを設定することで、これをオーバーライドできます:

  • quarkus.datasource.jdbc.transactions デフォルトの無名データソースの場合

  • quarkus.datasource. <datasource-name> .jdbc.transactions 名前付きデータソースの場合

詳細については、以下の 設定リファレンス のセクションを参照してください。

jdbcを使用してトランザクションログをデータベースに保存しやすくするには、 Quarkusのトランザクションの使用 ガイドの トランザクションログをデータソースに保存するように設定する セクションを参照してください。

名前付きデータソース

Dev Servicesを使用すると、デフォルトのデータソースが常に作成されますが、名前付きデータソースを指定するには、Quarkusがデータソースの作成方法を検出できるように、少なくとも1つのビルド時プロパティが必要です。

通常、 db-kind プロパティを指定するか、 quarkus.datasource."name".devservices.enabled=true を設定して明示的に Dev Services を有効にします。

インメモリーデータベースを使用したテスト

H2やDerbyのようないくつかのデータベースは、結合テストを迅速に実行するための機能として、 組み込み モードで一般的に使用されています。

特に、 dev Services がテスト用のゼロコンフィグデータベースを提供して おり、コンテナに対してテストを実行すると比較的短時間で実際の環境で期待通りの結果が得られる場合は、本番環境で使用する予定の実際のデータベースを使用することをお勧めします。しかし、単純な統合テストを実行する機能が必要なシナリオでは、JVM で動作するデータベースを使用することも可能です。

サポートと制限

組み込みデータベース(H2およびDerby)はJVMモードで動作します。 ネイティブモードでは、以下の制限が適用されます:

  • Derbyをネイティブモードでアプリケーションに組み込むことはできません。 しかし、Quarkus Derbyエクステンションを使用すると、Derby JDBC クライアント をネイティブにコンパイルして、 リモート 接続をサポートできます。

  • ネイティブイメージにH2を埋め込むことは推奨されません。 例えば、別のデータベースへのリモート接続を使用するなど、別の方法を検討してください。

統合テストの実行

  1. Add a dependency on the artifacts providing the additional tools that are under the following Maven coordinates:

    • io.quarkus:quarkus-test-h2 H2の場合

    • io.quarkus:quarkus-test-derby ダービーの場合

      これにより、アプリケーションをネイティブの実行可能ファイルにコンパイルしても、データベースはJVMプロセスとして実行されます。

  2. JVM とネイティブの実行可能ファイルの両方で統合テストを実行するために、結合テストの任意のクラスに以下の特定のアノテーションを追加します:

    • @QuarkusTestResource(H2DatabaseTestResource.class)

    • @QuarkusTestResource(DerbyDatabaseTestResource.class)

      これにより、テストスイートは、テスト実行に必要な別プロセスで管理データベースを起動し、終了します。

      H2の例
      package my.app.integrationtests.db;
      
      import io.quarkus.test.common.QuarkusTestResource;
      import io.quarkus.test.h2.H2DatabaseTestResource;
      
      @QuarkusTestResource(H2DatabaseTestResource.class)
      public class TestResources {
      }
  3. マネージドデータベースへの接続を設定します:

    quarkus.datasource.db-kind=h2
    quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test

参照

共通データソース設定リファレンス

ビルド時に固定される構成プロパティ - 他のすべての構成プロパティは実行時にオーバーライド可能

Configuration property

デフォルト

Whether or not a 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

Show more

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.

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

Show more

boolean

false

Datasources

デフォルト

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

Environment variable: QUARKUS_DATASOURCE_DB_KIND

Show more

string

The version of the database we will connect to (e.g. '10.0').

The version number set here should follow the same numbering scheme as the string returned by java.sql.DatabaseMetaData#getDatabaseProductVersion() for your database’s JDBC driver. This numbering scheme may be different from the most popular one for your database; for example Microsoft SQL Server 2016 would be version 13.

As a rule, the version set here should be as high as possible, but must be lower than or equal to the version of any database your application will connect to.

A high version will allow better performance and using more features (e.g. Hibernate ORM may generate more efficient SQL, avoid workarounds and take advantage of more database features), but if it is higher than the version of the database you want to connect to, it may lead to runtime exceptions (e.g. Hibernate ORM may generate invalid SQL that your database will reject).

Some extensions (like the Hibernate ORM extension) will try to check this version against the actual database version on startup, leading to a startup failure when the actual version is lower or simply a warning in case the database cannot be reached.

The default for this property is specific to each extension; the Hibernate ORM extension will default to the oldest version it supports.

Environment variable: QUARKUS_DATASOURCE_DB_VERSION

Show more

string

Whether this Dev Service should start with the application in dev mode or tests.

Dev Services are enabled by default unless connection configuration (e.g. the JDBC URL or reactive client URL) is set explicitly.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_ENABLED

Show more

boolean

The container image name for container-based Dev Service providers.

This has no effect if the provider is not a container-based database, such as H2 or Derby.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_IMAGE_NAME

Show more

string

Environment variables that are passed to the container.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_CONTAINER_ENV

Show more

Map<String,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

Show more

Map<String,String>

Generic properties that are added to the database connection URL.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_PROPERTIES

Show more

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_DEVSERVICES_PORT

Show more

int

The container start command to use for container-based Dev Service providers.

This has no effect if the provider is not a container-based database, such as H2 or Derby.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_COMMAND

Show more

string

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

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_DB_NAME

Show more

string

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

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_USERNAME

Show more

string

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

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_PASSWORD

Show more

string

The path to a SQL script to be loaded from the classpath and applied to the Dev Service database.

This has no effect if the provider is not a container-based database, such as H2 or Derby.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_INIT_SCRIPT_PATH

Show more

string

The volumes to be mapped to the container.

The map key corresponds to the host location; the map value is the container location. If the host location starts with "classpath:", the mapping loads the resource from the classpath with read-only permission.

When using a file system location, the volume will be generated with read-write permission, potentially leading to data loss or modification in your file system.

This has no effect if the provider is not a container-based database, such as H2 or Derby.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_VOLUMES

Show more

Map<String,String>

Whether to keep Dev Service containers running after a dev mode session or test suite execution to reuse them in the next dev mode session or test suite execution.

Within a dev mode session or test suite execution, Quarkus will always reuse Dev Services as long as their configuration (username, password, environment, port bindings, …​) did not change. This feature is specifically about keeping containers running when Quarkus is not running to reuse them across runs.

This feature needs to be enabled explicitly in testcontainers.properties, may require changes to how you configure data initialization in dev mode and tests, and may leave containers running indefinitely, forcing you to stop and remove them manually. See this section of the documentation for more information.

This configuration property is set to true by default, so it is mostly useful to disable reuse, if you enabled it in testcontainers.properties but only want to use it for some of your Quarkus applications or datasources.

Environment variable: QUARKUS_DATASOURCE_DEVSERVICES_REUSE

Show more

boolean

true

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

Show more

boolean

false

Whether this datasource should be active at runtime.

If the datasource is not active, it won’t start with the application, and accessing the corresponding Datasource CDI bean will fail, meaning in particular that consumers of this datasource (e.g. Hibernate ORM persistence units) will fail to start unless they are inactive too.

Environment variable: QUARKUS_DATASOURCE_ACTIVE

Show more

boolean

true

The datasource username

Environment variable: QUARKUS_DATASOURCE_USERNAME

Show more

string

The datasource password

Environment variable: QUARKUS_DATASOURCE_PASSWORD

Show more

string

The credentials provider name

Environment variable: QUARKUS_DATASOURCE_CREDENTIALS_PROVIDER

Show more

string

The credentials provider bean name.

This is a bean name (as in @Named) of a bean that implements CredentialsProvider. It is used to select the credentials provider bean when multiple exist. This is unnecessary when there is only one credentials provider available.

For Vault, the credentials provider bean name is vault-credentials-provider.

Environment variable: QUARKUS_DATASOURCE_CREDENTIALS_PROVIDER_NAME

Show more

string

JDBC 設定リファレンス

ビルド時に固定される構成プロパティ - 他のすべての構成プロパティは、実行時にオーバーライド可能

Configuration property

デフォルト

The datasource URL

Environment variable: QUARKUS_DATASOURCE_JDBC_URL

Show more

string

The initial size of the pool. Usually you will want to set the initial size to match at least the minimal size, but this is not enforced so to allow for architectures which prefer a lazy initialization of the connections on boot, while being able to sustain a minimal pool size after boot.

Environment variable: QUARKUS_DATASOURCE_JDBC_INITIAL_SIZE

Show more

int

The datasource pool minimum size

Environment variable: QUARKUS_DATASOURCE_JDBC_MIN_SIZE

Show more

int

0

The datasource pool maximum size

Environment variable: QUARKUS_DATASOURCE_JDBC_MAX_SIZE

Show more

int

20

The interval at which we validate idle connections in the background.

Set to 0 to disable background validation.

Environment variable: QUARKUS_DATASOURCE_JDBC_BACKGROUND_VALIDATION_INTERVAL

Show more

Duration

2M

Perform foreground validation on connections that have been idle for longer than the specified interval.

Environment variable: QUARKUS_DATASOURCE_JDBC_FOREGROUND_VALIDATION_INTERVAL

Show more

Duration

The timeout before cancelling the acquisition of a new connection

Environment variable: QUARKUS_DATASOURCE_JDBC_ACQUISITION_TIMEOUT

Show more

Duration

5S

The interval at which we check for connection leaks.

Environment variable: QUARKUS_DATASOURCE_JDBC_LEAK_DETECTION_INTERVAL

Show more

Duration

This feature is disabled by default.

The interval at which we try to remove idle connections.

Environment variable: QUARKUS_DATASOURCE_JDBC_IDLE_REMOVAL_INTERVAL

Show more

Duration

5M

The max lifetime of a connection.

Environment variable: QUARKUS_DATASOURCE_JDBC_MAX_LIFETIME

Show more

Duration

By default, there is no restriction on the lifespan of a connection.

The transaction isolation level.

Environment variable: QUARKUS_DATASOURCE_JDBC_TRANSACTION_ISOLATION_LEVEL

Show more

undefined, none, read-uncommitted, read-committed, repeatable-read, serializable

Collect and display extra troubleshooting info on leaked connections.

Environment variable: QUARKUS_DATASOURCE_JDBC_EXTENDED_LEAK_REPORT

Show more

boolean

false

Allows connections to be flushed upon return to the pool. It’s not enabled by default.

Environment variable: QUARKUS_DATASOURCE_JDBC_FLUSH_ON_CLOSE

Show more

boolean

false

When enabled, Agroal will be able to produce a warning when a connection is returned to the pool without the application having closed all open statements. This is unrelated with tracking of open connections. Disable for peak performance, but only when there’s high confidence that no leaks are happening.

Environment variable: QUARKUS_DATASOURCE_JDBC_DETECT_STATEMENT_LEAKS

Show more

boolean

true

Query executed when first using a connection.

Environment variable: QUARKUS_DATASOURCE_JDBC_NEW_CONNECTION_SQL

Show more

string

Query executed to validate a connection.

Environment variable: QUARKUS_DATASOURCE_JDBC_VALIDATION_QUERY_SQL

Show more

string

Disable pooling to prevent reuse of Connections. Use this when an external pool manages the life-cycle of Connections.

Environment variable: QUARKUS_DATASOURCE_JDBC_POOLING_ENABLED

Show more

boolean

true

Require an active transaction when acquiring a connection. Recommended for production. WARNING: Some extensions acquire connections without holding a transaction for things like schema updates and schema validation. Setting this setting to STRICT may lead to failures in those cases.

Environment variable: QUARKUS_DATASOURCE_JDBC_TRANSACTION_REQUIREMENT

Show more

off, warn, strict

Enable JDBC tracing.

Environment variable: QUARKUS_DATASOURCE_JDBC_TRACING_ENABLED

Show more

boolean

false if quarkus.datasource.jdbc.tracing=false and true if quarkus.datasource.jdbc.tracing=true

Trace calls with active Spans only

Environment variable: QUARKUS_DATASOURCE_JDBC_TRACING_TRACE_WITH_ACTIVE_SPAN_ONLY

Show more

boolean

false

Ignore specific queries from being traced

Environment variable: QUARKUS_DATASOURCE_JDBC_TRACING_IGNORE_FOR_TRACING

Show more

string

Ignore specific queries from being traced, multiple queries can be specified separated by semicolon, double quotes should be escaped with \

Enable OpenTelemetry JDBC instrumentation.

Environment variable: QUARKUS_DATASOURCE_JDBC_TELEMETRY_ENABLED

Show more

boolean

false if quarkus.datasource.jdbc.telemetry=false and true if quarkus.datasource.jdbc.telemetry=true

Other unspecified properties to be passed to the JDBC driver when creating new connections.

Environment variable: QUARKUS_DATASOURCE_JDBC_ADDITIONAL_JDBC_PROPERTIES

Show more

Map<String,String>

Datasources

デフォルト

If we create a JDBC datasource for this datasource.

Environment variable: QUARKUS_DATASOURCE_JDBC

Show more

boolean

true

The datasource driver class name

Environment variable: QUARKUS_DATASOURCE_JDBC_DRIVER

Show more

string

Whether we want to use regular JDBC transactions, XA, or disable all transactional capabilities.

When enabling XA you will need a driver implementing javax.sql.XADataSource.

Environment variable: QUARKUS_DATASOURCE_JDBC_TRANSACTIONS

Show more

enabled, xa, disabled

enabled

Enable datasource metrics collection. If unspecified, collecting metrics will be enabled by default if a metrics extension is active.

Environment variable: QUARKUS_DATASOURCE_JDBC_ENABLE_METRICS

Show more

boolean

Enable JDBC tracing. Disabled by default.

Environment variable: QUARKUS_DATASOURCE_JDBC_TRACING

Show more

boolean

false

Enable OpenTelemetry JDBC instrumentation.

Environment variable: QUARKUS_DATASOURCE_JDBC_TELEMETRY

Show more

boolean

false

Additional named datasources

デフォルト

The datasource URL

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_URL

Show more

string

The initial size of the pool. Usually you will want to set the initial size to match at least the minimal size, but this is not enforced so to allow for architectures which prefer a lazy initialization of the connections on boot, while being able to sustain a minimal pool size after boot.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_INITIAL_SIZE

Show more

int

The datasource pool minimum size

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_MIN_SIZE

Show more

int

0

The datasource pool maximum size

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_MAX_SIZE

Show more

int

20

The interval at which we validate idle connections in the background.

Set to 0 to disable background validation.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_BACKGROUND_VALIDATION_INTERVAL

Show more

Duration

2M

Perform foreground validation on connections that have been idle for longer than the specified interval.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_FOREGROUND_VALIDATION_INTERVAL

Show more

Duration

The timeout before cancelling the acquisition of a new connection

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_ACQUISITION_TIMEOUT

Show more

Duration

5S

The interval at which we check for connection leaks.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_LEAK_DETECTION_INTERVAL

Show more

Duration

This feature is disabled by default.

The interval at which we try to remove idle connections.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_IDLE_REMOVAL_INTERVAL

Show more

Duration

5M

The max lifetime of a connection.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_MAX_LIFETIME

Show more

Duration

By default, there is no restriction on the lifespan of a connection.

The transaction isolation level.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_TRANSACTION_ISOLATION_LEVEL

Show more

undefined, none, read-uncommitted, read-committed, repeatable-read, serializable

Collect and display extra troubleshooting info on leaked connections.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_EXTENDED_LEAK_REPORT

Show more

boolean

false

Allows connections to be flushed upon return to the pool. It’s not enabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_FLUSH_ON_CLOSE

Show more

boolean

false

When enabled, Agroal will be able to produce a warning when a connection is returned to the pool without the application having closed all open statements. This is unrelated with tracking of open connections. Disable for peak performance, but only when there’s high confidence that no leaks are happening.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_DETECT_STATEMENT_LEAKS

Show more

boolean

true

Query executed when first using a connection.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_NEW_CONNECTION_SQL

Show more

string

Query executed to validate a connection.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_VALIDATION_QUERY_SQL

Show more

string

Disable pooling to prevent reuse of Connections. Use this when an external pool manages the life-cycle of Connections.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_POOLING_ENABLED

Show more

boolean

true

Require an active transaction when acquiring a connection. Recommended for production. WARNING: Some extensions acquire connections without holding a transaction for things like schema updates and schema validation. Setting this setting to STRICT may lead to failures in those cases.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_TRANSACTION_REQUIREMENT

Show more

off, warn, strict

Other unspecified properties to be passed to the JDBC driver when creating new connections.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_ADDITIONAL_JDBC_PROPERTIES

Show more

Map<String,String>

Enable JDBC tracing.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_TRACING_ENABLED

Show more

boolean

false if quarkus.datasource.jdbc.tracing=false and true if quarkus.datasource.jdbc.tracing=true

Trace calls with active Spans only

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_TRACING_TRACE_WITH_ACTIVE_SPAN_ONLY

Show more

boolean

false

Ignore specific queries from being traced

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_TRACING_IGNORE_FOR_TRACING

Show more

string

Ignore specific queries from being traced, multiple queries can be specified separated by semicolon, double quotes should be escaped with \

Enable OpenTelemetry JDBC instrumentation.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__JDBC_TELEMETRY_ENABLED

Show more

boolean

false if quarkus.datasource.jdbc.telemetry=false and true if quarkus.datasource.jdbc.telemetry=true

期間フォーマットについて

To write duration values, use the standard java.time.Duration format. See the Duration#parse() Java API documentation for more information.

数字で始まる簡略化した書式を使うこともできます:

  • 数値のみの場合は、秒単位の時間を表します。

  • 数値の後に ms が続く場合は、ミリ秒単位の時間を表します。

その他の場合は、簡略化されたフォーマットが解析のために java.time.Duration フォーマットに変換されます:

  • 数値の後に hms が続く場合は、その前に PT が付けられます。

  • 数値の後に d が続く場合は、その前に P が付けられます。

JDBC URL リファレンス

サポートされているデータベースには、それぞれ異なる JDBC URL 設定オプションがあります。以下のセクションでは、各データベース URL の概要と公式ドキュメントへのリンクを示します。

DB2

jdbc:db2://<serverName>[:<portNumber>]/<databaseName>[:<key1>=<value>;[<key2>=<value2>;]]

jdbc:db2://localhost:50000/MYDB:user=dbadm;password=dbadm;

URL構文と追加のサポートされるオプションの詳細については、 公式ドキュメント を参照してください。

Derby

jdbc:derby:[//serverName[:portNumber]/][memory:]databaseName[;property=value[;property=value]]

jdbc:derby://localhost:1527/myDB, jdbc:derby:memory:myDB;create=true

Derbyは組み込みデータベースであり、サーバーとして実行することも、ファイルに基づいて実行することも、完全にメモリ内で実行することもできます。上記のオプションはすべて利用可能です。

詳しくは 公式ドキュメント をご覧ください。

H2

jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value…​]

jdbc:h2:tcp://localhost/~/test, jdbc:h2:mem:myDB

H2は、組み込みモードでもサーバーモードでも動作するデータベースです。 ファイルストレージを使用することも、完全にメモリ内で実行することもできます。 これらのオプションはすべて、上記のように利用可能です。

詳しくは 公式ドキュメント をご覧ください。

MariaDB

jdbc:mariadb:[replication:|failover:|sequential:|aurora:]//<hostDescription>[,<hostDescription>…​]/[database][?<key1>=<value1>[&<key2>=<value2>]] hostDescription:: <host>[:<portnumber>] or address=(host=<host>)[(port=<portnumber>)][(type=(master|slave))]

jdbc:mariadb://localhost:3306/test

詳しくは 公式ドキュメント をご覧ください。

Microsoft SQL server

jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]

jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks

Microsoft SQL Server JDBC ドライバーは、基本的に他のドライバーと同じように動作します。

詳しくは 公式ドキュメント をご覧ください。

MySQL

jdbc:mysql:[replication:|failover:|sequential:|aurora:]//<hostDescription>[,<hostDescription>…​]/[database][?<key1>=<value1>[&<key2>=<value2>]] hostDescription:: <host>[:<portnumber>] or address=(host=<host>)[(port=<portnumber>)][(type=(master|slave))]

jdbc:mysql://localhost:3306/test

詳しくは 公式ドキュメント をご覧ください。

MySQL の制限

Quarkusアプリケーションをネイティブイメージにコンパイルする場合、MySQLのJMXサポートとOracle Cloud Infrastructure(OCI)統合は、GraalVMネイティブイメージと互換性がないため、無効になります。

  • JMXのサポートがないのは、ネイティブモードで実行することの当然の結果であり、解決される見込みはありません。

  • OCIとの統合はサポートされていません。

Oracle

jdbc:oracle:driver_type:@database_specifier

jdbc:oracle:thin:@localhost:1521/ORCL_SVC

詳しくは 公式ドキュメント をご覧ください。

PostgreSQL

jdbc:postgresql:[//][host][:port][/database][?key=value…​]

jdbc:postgresql://localhost/test

各パートのデフォルトは以下の通り:

host

localhost

port

5432

database

ユーザー名と同じ名前

For more information about additional parameters, see the official documentation.

Quarkusエクステンションとデータベースドライバーのリファレンス

The following tables list the built-in db-kind values, the corresponding Quarkus extensions, and the JDBC drivers used by those extensions.

When using one of the built-in datasource kinds, the JDBC and Reactive drivers are resolved automatically to match the values from these tables.

Table 1. Database platform kind to JDBC driver mapping
データベースの種類 Quarkusエクステンション Drivers

db2

quarkus-jdbc-db2

  • JDBC: com.ibm.db2.jcc.DB2Driver

  • XA: com.ibm.db2.jcc.DB2XADataSource

derby

quarkus-jdbc-derby

  • JDBC: org.apache.derby.jdbc.ClientDriver

  • XA: org.apache.derby.jdbc.ClientXADataSource

h2

quarkus-jdbc-h2

  • JDBC: org.h2.Driver

  • XA: org.h2.jdbcx.JdbcDataSource

mariadb

quarkus-jdbc-mariadb

  • JDBC: org.mariadb.jdbc.Driver

  • XA: org.mariadb.jdbc.MySQLDataSource

mssql

quarkus-jdbc-mssql

  • JDBC: com.microsoft.sqlserver.jdbc.SQLServerDriver

  • XA: com.microsoft.sqlserver.jdbc.SQLServerXADataSource

mysql

quarkus-jdbc-mysql

  • JDBC: com.mysql.cj.jdbc.Driver

  • XA: com.mysql.cj.jdbc.MysqlXADataSource

oracle

quarkus-jdbc-oracle

  • JDBC: oracle.jdbc.driver.OracleDriver

  • XA: oracle.jdbc.xa.client.OracleXADataSource

postgresql

quarkus-jdbc-postgresql

  • JDBC: org.postgresql.Driver

  • XA: org.postgresql.xa.PGXADataSource

Table 2. データベースの種類と Reactive ドライバーのマッピング
データベースの種類 Quarkusエクステンション ドライバー

oracle

reactive-oracle-client

io.vertx.oracleclient.spi.OracleDriver

mysql

reactive-mysql-client

io.vertx.mysqlclient.spi.MySQLDriver

mssql

reactive-mssql-client

io.vertx.mssqlclient.spi.MSSQLDriver

postgresql

reactive-pg-client

io.vertx.pgclient.spi.PgDriver

db2

reactive-db2-client

io.vertx.db2client.spi.DB2Driver

この自動解決はほとんどの場合に適用可能であり、ドライバーの設定は必要ありません。

Reactive データソース設定リファレンス

ビルド時に固定される設定プロパティ - 他のすべての設定プロパティは、実行時にオーバーライド可能

Configuration property

デフォルト

If we create a Reactive datasource for this datasource.

Environment variable: QUARKUS_DATASOURCE_REACTIVE

Show more

boolean

true

Whether prepared statements should be cached on the client side.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_CACHE_PREPARED_STATEMENTS

Show more

boolean

false

The datasource URLs.

If multiple values are set, this datasource will create a pool with a list of servers instead of a single server. The pool uses round-robin load balancing for server selection during connection establishment. Note that certain drivers might not accommodate multiple values in this context.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_URL

Show more

list of string

The datasource pool maximum size.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MAX_SIZE

Show more

int

20

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

Show more

int

Whether all server certificates should be trusted.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_ALL

Show more

boolean

false

PEM Trust config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_PEM

Show more

boolean

false

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

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_PEM_CERTS

Show more

list of string

JKS config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_JKS

Show more

boolean

false

Path of the key file (JKS format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_JKS_PATH

Show more

string

Password of the key file.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_JKS_PASSWORD

Show more

string

PFX config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_PFX

Show more

boolean

false

Path to the key file (PFX format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_PFX_PATH

Show more

string

Password of the key.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_TRUST_CERTIFICATE_PFX_PASSWORD

Show more

string

PEM Key/cert config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PEM

Show more

boolean

false

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

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PEM_KEYS

Show more

list of string

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

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PEM_CERTS

Show more

list of string

JKS config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_JKS

Show more

boolean

false

Path of the key file (JKS format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_JKS_PATH

Show more

string

Password of the key file.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_JKS_PASSWORD

Show more

string

PFX config is disabled by default.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PFX

Show more

boolean

false

Path to the key file (PFX format).

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PFX_PATH

Show more

string

Password of the key.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_KEY_CERTIFICATE_PFX_PASSWORD

Show more

string

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

Environment variable: QUARKUS_DATASOURCE_REACTIVE_RECONNECT_ATTEMPTS

Show more

int

0

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

Environment variable: QUARKUS_DATASOURCE_REACTIVE_RECONNECT_INTERVAL

Show more

Duration

PT1S

The hostname verification algorithm to use in case the server’s identity should be checked. Should be HTTPS, LDAPS or NONE. NONE is the default value and disables the verification.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_HOSTNAME_VERIFICATION_ALGORITHM

Show more

string

NONE

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

Environment variable: QUARKUS_DATASOURCE_REACTIVE_IDLE_TIMEOUT

Show more

Duration

no timeout

The maximum time a connection remains in the pool, after which it will be closed upon return and replaced as necessary.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MAX_LIFETIME

Show more

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

Show more

boolean

false

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

Environment variable: QUARKUS_DATASOURCE_REACTIVE_NAME

Show more

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

Show more

Map<String,String>

Additional named datasources

デフォルト

If we create a Reactive datasource for this datasource.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE

Show more

boolean

true

Whether prepared statements should be cached on the client side.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_CACHE_PREPARED_STATEMENTS

Show more

boolean

false

The datasource URLs.

If multiple values are set, this datasource will create a pool with a list of servers instead of a single server. The pool uses round-robin load balancing for server selection during connection establishment. Note that certain drivers might not accommodate multiple values in this context.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_URL

Show more

list of string

The datasource pool maximum size.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_MAX_SIZE

Show more

int

20

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

Show more

int

Whether all server certificates should be trusted.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_ALL

Show more

boolean

false

PEM Trust config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_PEM

Show more

boolean

false

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

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_PEM_CERTS

Show more

list of string

JKS config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_JKS

Show more

boolean

false

Path of the key file (JKS format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_JKS_PATH

Show more

string

Password of the key file.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_JKS_PASSWORD

Show more

string

PFX config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_PFX

Show more

boolean

false

Path to the key file (PFX format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_PFX_PATH

Show more

string

Password of the key.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_TRUST_CERTIFICATE_PFX_PASSWORD

Show more

string

PEM Key/cert config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_PEM

Show more

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

Show more

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

Show more

list of string

JKS config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_JKS

Show more

boolean

false

Path of the key file (JKS format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_JKS_PATH

Show more

string

Password of the key file.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_JKS_PASSWORD

Show more

string

PFX config is disabled by default.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_PFX

Show more

boolean

false

Path to the key file (PFX format).

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_PFX_PATH

Show more

string

Password of the key.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_KEY_CERTIFICATE_PFX_PASSWORD

Show more

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

Show more

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

Show more

Duration

PT1S

The hostname verification algorithm to use in case the server’s identity should be checked. Should be HTTPS, LDAPS or NONE. NONE is the default value and disables the verification.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_HOSTNAME_VERIFICATION_ALGORITHM

Show more

string

NONE

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

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_IDLE_TIMEOUT

Show more

Duration

no timeout

The maximum time a connection remains in the pool, after which it will be closed upon return and replaced as necessary.

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_MAX_LIFETIME

Show more

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

Show more

boolean

false

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

Environment variable: QUARKUS_DATASOURCE__DATASOURCE_NAME__REACTIVE_NAME

Show more

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

Show more

Map<String,String>

期間フォーマットについて

To write duration values, use the standard java.time.Duration format. See the Duration#parse() Java API documentation for more information.

数字で始まる簡略化した書式を使うこともできます:

  • 数値のみの場合は、秒単位の時間を表します。

  • 数値の後に ms が続く場合は、ミリ秒単位の時間を表します。

その他の場合は、簡略化されたフォーマットが解析のために java.time.Duration フォーマットに変換されます:

  • 数値の後に hms が続く場合は、その前に PT が付けられます。

  • 数値の後に d が続く場合は、その前に P が付けられます。

Reactive DB2 設定

ビルド時に固定される設定プロパティ - 他のすべての設定プロパティは、実行時にオーバーライド可能

Datasources

デフォルト

Whether SSL/TLS is enabled.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_DB2_SSL

Show more

boolean

false

Reactive MariaDB/MySQL固有の設定

ビルド時に固定される設定プロパティ - 他のすべての設定プロパティは、実行時にオーバーライド可能

Additional named datasources

デフォルト

Charset for connections.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MYSQL_CHARSET

Show more

string

Collation for connections.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MYSQL_COLLATION

Show more

string

Desired security state of the connection to the server.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MYSQL_SSL_MODE

Show more

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

disabled

Connection timeout in seconds

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MYSQL_CONNECTION_TIMEOUT

Show more

int

The authentication plugin the client should use. By default, it uses the plugin name specified by the server in the initial handshake packet.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MYSQL_AUTHENTICATION_PLUGIN

Show more

default, mysql-clear-password, mysql-native-password, sha256-password, caching-sha2-password

default

The maximum number of inflight database commands that can be pipelined. By default, pipelining is disabled.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MYSQL_PIPELINING_LIMIT

Show more

int

Whether to return the number of rows matched by the WHERE clause in UPDATE statements, instead of the number of rows actually changed.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MYSQL_USE_AFFECTED_ROWS

Show more

ブーリアン

false

Reactive Microsoft SQLサーバー固有の設定

ビルド時に固定される設定プロパティ - 他のすべての設定プロパティは、実行時にオーバーライド可能

Datasources

デフォルト

The desired size (in bytes) for TDS packets.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MSSQL_PACKET_SIZE

Show more

int

Whether SSL/TLS is enabled.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_MSSQL_SSL

Show more

boolean

false

Reactive Oracle固有の設定

ビルド時に固定される設定プロパティ - 他のすべての設定プロパティは、実行時にオーバーライド可能

Datasources

デフォルト

Reactive PostgreSQL固有の設定

ビルド時に固定される設定プロパティ - 他のすべての設定プロパティは、実行時にオーバーライド可能

Datasources

デフォルト

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

Environment variable: QUARKUS_DATASOURCE_REACTIVE_POSTGRESQL_PIPELINING_LIMIT

Show more

int

SSL operating mode of the client.

Environment variable: QUARKUS_DATASOURCE_REACTIVE_POSTGRESQL_SSL_MODE

Show more

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

disable

Level 7 proxies can load balance queries on several connections to the actual database. When it happens, the client can be confused by the lack of session affinity and unwanted errors can happen like ERROR: unnamed prepared statement does not exist (26000). See Using a level 7 proxy

Environment variable: QUARKUS_DATASOURCE_REACTIVE_POSTGRESQL_USE_LAYER7_PROXY

Show more

boolean

false

Reactive データソースの URL 参照

DB2

db2://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]

db2://dbuser:secretpassword@database.server.com:50000/mydb

現在、クライアントは以下のパラメータキーをサポートしています:

  • host

  • port

  • user

  • password

  • database

接続 URL でパラメータを設定すると、デフォルトのプロパティが上書きされます。

Microsoft SQL server

sqlserver://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]

sqlserver://dbuser:secretpassword@database.server.com:1433/mydb

現在、クライアントは以下のパラメータキーをサポートしています:

  • host

  • port

  • user

  • password

  • database

接続 URL でパラメータを設定すると、デフォルトのプロパティが上書きされます。

MySQL / MariaDB

mysql://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]

mysql://dbuser:secretpassword@database.server.com:3211/mydb

現在、クライアントは以下のパラメータキーをサポートしています(大文字と小文字を区別します):

  • host

  • port

  • user

  • password

  • schema

  • socket

  • useAffectedRows

接続 URL でパラメータを設定すると、デフォルトのプロパティが上書きされます。

Oracle

EZConnect 形式

oracle:thin:@[[protocol:]//]host[:port][/service_name][:server_mode][/instance_name][?connection properties]

oracle:thin:@mydbhost1:5521/mydbservice?connect_timeout=10sec

TNSエイリアス形式

oracle:thin:@<alias_name>[?connection properties]

oracle:thin:@prod_db?TNS_ADMIN=/work/tns/

PostgreSQL

postgresql://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]

postgresql://dbuser:secretpassword@database.server.com:5432/mydb

現在、クライアントは以下をサポートしています:

  • 以下のパラメータキー:

    • host

    • port

    • user

    • password

    • dbname

    • sslmode

  • 次のような追加のプロパティ:

    • application_name

    • fallback_application_name

    • search_path

    • options

接続 URL でパラメータを設定すると、デフォルトのプロパティが上書きされます。

関連コンテンツ