이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 1. Configure data sources in Red Hat build of Quarkus
Use a unified configuration model to define data sources for Java Database Connectivity (JDBC) and Reactive drivers.
Applications use datasources to access relational databases. Quarkus provides a unified configuration model to define datasources for Java Database Connectivity (JDBC) and Reactive database drivers.
Quarkus uses Agroal and Vert.x to provide high-performance, scalable datasource connection pooling for JDBC and reactive drivers. The quarkus-jdbc-*
and quarkus-reactive-*-client
extensions provide build time optimizations and integrate configured datasources with Quarkus features like security, health checks, and metrics.
For more information about consuming and using a reactive datasource, see the Quarkus Reactive SQL clients guide.
Additionally, refer to the Quarkus Hibernate ORM guide for information on consuming and using a JDBC datasource.
1.1. Get started with configuring datasources in Quarkus 링크 복사링크가 클립보드에 복사되었습니다!
For users familiar with the fundamentals, this section provides an overview and code samples to set up datasources quickly.
For more advanced configuration with examples, see References.
1.1.1. Zero-config setup in development mode 링크 복사링크가 클립보드에 복사되었습니다!
Quarkus simplifies database configuration by offering the Dev Services feature, enabling zero-config database setup for testing or running in development (dev) mode. In dev mode, the suggested approach is to use DevServices and let Quarkus handle the database for you, whereas for production mode, you provide explicit database configuration details pointing to a database managed outside of Quarkus.
To use Dev Services, add the appropriate driver extension, such as jdbc-postgresql
, for your desired database type to the pom.xml
file. In dev mode, if you do not provide any explicit database connection details, Quarkus automatically handles the database setup and provides the wiring between the application and the database.
If you provide user credentials, the underlying database will be configured to use them. This is useful if you want to connect to the database with an external tool.
To use this feature, ensure a Docker or Podman container runtime is installed, depending on the database type. Certain databases, such as H2, operate in in-memory mode and do not require a container runtime.
Prefix the actual connection details for prod mode with %prod.
to ensure they are not applied in dev mode. For more information, see the Profiles section of the "Configuration reference" guide.
For more information about Dev Services, see Dev Services overview.
For more details and optional configurations, see Dev Services for databases.
1.1.2. Configure a JDBC datasource 링크 복사링크가 클립보드에 복사되었습니다!
Add the correct JDBC extension for the database of your choice.
-
quarkus-jdbc-db2
quarkus-jdbc-derby
NoteThe Apache Derby database is deprecated in Red Hat build of Quarkus 3.20 and is planned to be removed in a future release. Red Hat will continue to provide development support for Apache Derby during the current release lifecycle.
-
quarkus-jdbc-h2
-
quarkus-jdbc-mariadb
-
quarkus-jdbc-mssql
-
quarkus-jdbc-mysql
-
quarkus-jdbc-oracle
-
quarkus-jdbc-postgresql
-
Configure your JDBC datasource:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- This configuration value is only required if there is more than one database extension on the classpath.
If only one viable extension is available, Quarkus assumes this is the correct one. When you add a driver to the test scope, Quarkus automatically includes the specified driver in testing.
1.1.2.1. JDBC connection pool size adjustment 링크 복사링크가 클립보드에 복사되었습니다!
To protect your database from overloading during load peaks, size the pool adequately to throttle the database load. The optimal pool size depends on many factors, such as the number of parallel application users or the nature of the workload.
Be aware that setting the pool size too low might cause some requests to time out while waiting for a connection.
For more information about pool size adjustment properties, see the JDBC configuration reference section.
1.1.3. Configure a reactive datasource 링크 복사링크가 클립보드에 복사되었습니다!
Add the correct reactive extension for the database of your choice.
-
quarkus-reactive-mssql-client
-
quarkus-reactive-mysql-client
-
quarkus-reactive-oracle-client
-
quarkus-reactive-pg-client
-
Configure your reactive datasource:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- This configuration value is only required if there is more than one Reactive driver extension on the classpath.
1.2. Configure datasources 링크 복사링크가 클립보드에 복사되었습니다!
The following section describes the configuration for single or multiple datasources. For simplicity, we will reference a single datasource as the default (unnamed) datasource.
1.2.1. Configure a single datasource 링크 복사링크가 클립보드에 복사되었습니다!
A datasource can be either a JDBC datasource, reactive, or both. This depends on the configuration and the selection of project extensions.
Define a datasource with the following configuration property, where
db-kind
defines which database platform to connect to, for example,h2
:quarkus.datasource.db-kind=h2
quarkus.datasource.db-kind=h2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Quarkus deduces the JDBC driver class it needs to use from the specified value of the
db-kind
database platform attribute.NoteThis step is required only if your application depends on multiple database drivers. If the application operates with a single driver, this driver is detected automatically.
Quarkus currently includes the following built-in database kinds:
-
DB2:
db2
Derby:
derby
NoteThe Apache Derby database is deprecated in Red Hat build of Quarkus 3.20 and is planned to be removed in a future release. Red Hat will continue to provide development support for Apache Derby during the current release lifecycle.
-
H2:
h2
-
MariaDB:
mariadb
-
Microsoft SQL Server:
mssql
-
MySQL:
mysql
-
Oracle:
oracle
-
PostgreSQL:
postgresql
,pgsql
orpg
To use a database kind that is not built-in, use
other
and define the JDBC driver explicitlyNoteYou can use any JDBC driver in a Quarkus app in JVM mode as described in Custom databases and drivers. However, using a non-built-in database kind is unlikely to work when compiling your application to a native executable.
For native executable builds, it is recommended to either use the available JDBC Quarkus extensions or contribute a custom extension for your specific driver.
-
DB2:
Configure the following properties to define credentials:
quarkus.datasource.username=<your username> quarkus.datasource.password=<your password>
quarkus.datasource.username=<your username> quarkus.datasource.password=<your password>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can also retrieve the password from Vault by using a credential provider for your datasource.
Until now, the configuration has been the same regardless of whether you are using a JDBC or a reactive driver. When you have defined the database kind and the credentials, the rest depends on what type of driver you are using. It is possible to use JDBC and a reactive driver simultaneously.
1.2.1.1. JDBC datasource 링크 복사링크가 클립보드에 복사되었습니다!
JDBC is the most common database connection pattern, typically needed when used in combination with non-reactive Hibernate ORM.
To use a JDBC datasource, start with adding the necessary dependencies:
For use with a built-in JDBC driver, choose and add the Quarkus extension for your relational database driver from the list below:
Derby -
quarkus-jdbc-derby
NoteThe Apache Derby database is deprecated in Red Hat build of Quarkus 3.20 and is planned to be removed in a future release. Red Hat will continue to provide development support for Apache Derby during the current release lifecycle.
H2 -
quarkus-jdbc-h2
NoteH2 and Derby databases can be configured to run in "embedded mode"; however, the Derby extension does not support compiling the embedded database engine into native executables.
Read Testing with in-memory databases for suggestions regarding integration testing.
-
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
For example, to add the PostgreSQL driver dependency:
./mvnw quarkus:add-extension -Dextensions="jdbc-postgresql"
./mvnw quarkus:add-extension -Dextensions="jdbc-postgresql"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteUsing a built-in JDBC driver extension automatically includes the Agroal extension, which is the JDBC connection pool implementation applicable for custom and built-in JDBC drivers. However, for custom drivers, Agroal needs to be added explicitly.
For use with a custom JDBC driver, add the
quarkus-agroal
dependency to your project alongside the extension for your relational database driver:./mvnw quarkus:add-extension -Dextensions="agroal"
./mvnw quarkus:add-extension -Dextensions="agroal"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To use a JDBC driver for another database, use a database with no built-in extension or with a different driver.
Configure the JDBC connection by defining the JDBC URL property:
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/hibernate_orm_test
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/hibernate_orm_test
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteNote the
jdbc
prefix in the property name. All the configuration properties specific to JDBC have thejdbc
prefix. For reactive datasources, the prefix isreactive
.
For more information about configuring JDBC, see JDBC URL format reference and Quarkus extensions and database drivers reference.
1.2.1.1.1. Custom databases and drivers 링크 복사링크가 클립보드에 복사되었습니다!
If Quarkus does not provide a JDBC extension for your database, or you need to use a different JDBC driver, such as one for OpenTelemetry, you can configure the JDBC driver explicitly.
Without an extension, JDBC drivers are expected to work correctly in JVM mode. However, they are unlikely to function when compiling your application into a native executable. To build a native executable, use an existing Quarkus JDBC extension or contribute a new extension for your driver.
An example for defining access to a database with no built-in support in JVM mode:
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
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
For all the details about the JDBC configuration options and configuring other aspects, such as the connection pool size, refer to the JDBC configuration reference section.
1.2.1.1.2. Consuming the datasource 링크 복사링크가 클립보드에 복사되었습니다!
With Hibernate ORM, the Hibernate layer automatically picks up the datasource and uses it.
For the in-code access to the datasource, obtain it as any other bean as follows:
@Inject AgroalDataSource defaultDataSource;
@Inject
AgroalDataSource defaultDataSource;
In the above example, the type is AgroalDataSource
, a javax.sql.DataSource
subtype. Because of this, you can also use javax.sql.DataSource
as the injected type.
1.2.1.1.3. Oracle considerations 링크 복사링크가 클립보드에 복사되었습니다!
As documented in issue #36265, Oracle unexpectedly commits uncommitted transactions when closing a connection. This means that when stopping Quarkus, in-progress transactions might be committed even if they are incomplete.
Because this behavior is unexpected and can lead to data loss, an interceptor rolls back any unfinished transactions when closing a connection. However, if you use XA transactions, the transaction manager handles the rollback.
If the behavior introduced in 3.18 causes issues for your workload, disable it by setting the -Dquarkus-oracle-no-automatic-rollback-on-connection-close
system property to true
. Make sure to report your use case in our issue tracker so we can adjust this behavior if needed, for example, with more permanent settings.
1.2.1.2. Reactive datasource 링크 복사링크가 클립보드에 복사되었습니다!
Quarkus offers several reactive clients for use with a reactive datasource.
Add the corresponding extension to your application:
-
MariaDB/MySQL:
quarkus-reactive-mysql-client
-
Microsoft SQL Server:
quarkus-reactive-mssql-client
-
Oracle:
quarkus-reactive-oracle-client
PostgreSQL:
quarkus-reactive-pg-client
The installed extension must be consistent with the
quarkus.datasource.db-kind
you define in your datasource configuration.
-
MariaDB/MySQL:
After adding the driver, configure the connection URL and define a proper size for your connection pool.
quarkus.datasource.reactive.url=postgresql:///your_database quarkus.datasource.reactive.max-size=20
quarkus.datasource.reactive.url=postgresql:///your_database quarkus.datasource.reactive.max-size=20
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.2.1.2.1. Reactive connection pool size adjustment 링크 복사링크가 클립보드에 복사되었습니다!
To protect your database from overloading during load peaks, size the pool adequately to throttle the database load. The proper size always depends on many factors, such as the number of parallel application users or the nature of the workload.
Be aware that setting the pool size too low might cause some requests to time out while waiting for a connection.
For more information about pool size adjustment properties, see the Reactive datasource configuration reference section.
1.2.1.3. JDBC and reactive datasources simultaneously 링크 복사링크가 클립보드에 복사되었습니다!
When both a JDBC extension and a reactive datasource extension for the same database kind are included, both JDBC and reactive datasources will be created by default.
To use the JDBC and reactive datasources simultaneously:
%prod.quarkus.datasource.reactive.url=postgresql:///your_database %prod.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/hibernate_orm_test
%prod.quarkus.datasource.reactive.url=postgresql:///your_database %prod.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/hibernate_orm_test
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
If you do not want to have both a JDBC datasource and a reactive datasource created, use the following configuration.
To disable the JDBC datasource explicitly:
quarkus.datasource.jdbc=false
quarkus.datasource.jdbc=false
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To disable the reactive datasource explicitly:
quarkus.datasource.reactive=false
quarkus.datasource.reactive=false
Copy to Clipboard Copied! Toggle word wrap Toggle overflow TipIn most cases, the configuration above will be optional as either a JDBC driver or a reactive datasource extension will be present, not both.
1.2.2. Configure multiple datasources 링크 복사링크가 클립보드에 복사되었습니다!
The Hibernate ORM extension supports defining persistence units by using configuration properties. For each persistence unit, point to the datasource of your choice.
Defining multiple datasources works like defining a single datasource, with one important change - you have to specify a name (configuration property) for each datasource.
The following example provides three different datasources:
- the default one
-
a datasource named
users
-
a datasource named
inventory
Each with its configuration:
Notice there is an extra section in the configuration property. The syntax is as follows: quarkus.datasource.[optional name.][datasource property]
.
Even when only one database extension is installed, named databases need to specify at least one build-time property so that Quarkus can detect them. Generally, this is the db-kind
property, but you can also specify Dev Services properties to create named datasources according to the Dev Services for Databases guide.
1.2.2.1. Named datasource injection 링크 복사링크가 클립보드에 복사되었습니다!
When using multiple datasources, each DataSource
also has the io.quarkus.agroal.DataSource
qualifier with the name of the datasource as the value.
By using the properties mentioned in the previous section to configure three different datasources, inject each one of them as follows:
1.2.3. Activate or deactivate datasources 링크 복사링크가 클립보드에 복사되었습니다!
When a datasource is configured at build time, and its URL is set at runtime, it is active by default. Quarkus starts the corresponding JDBC connection pool or reactive client when the application starts.
To deactivate a datasource at runtime, either:
-
Do not set
quarkus.datasource[.optional name].jdbc.url
orquarkus.datasource[.optional name].reactive.url
. -
Set
quarkus.datasource[.optional name].active
tofalse
.
If a datasource is not active:
- The datasource does not attempt to connect to the database during application startup.
- The datasource does not contribute a health check.
-
Static CDI injection points involving the datasource, such as
@Inject DataSource ds
or@Inject Pool pool
, cause application startup to fail. -
Dynamic retrieval of the datasource, such as through
CDI.getBeanContainer()
,Arc.instance()
, or by injecting anInstance<DataSource>
, causes an exception to be thrown. Other Quarkus extensions that consume the datasource may cause application startup to fail.
In this case, you must also deactivate those other extensions. To see an example of this scenario, refer to this section of the Hibernate ORM guide.
This feature is especially useful when the application must select one datasource from a predefined set at runtime.
An example of configuring multiple datasources for runtime selection:
Setting quarkus.datasource."pg".active=true
at runtime makes only the PostgreSQL datasource available. Setting quarkus.datasource."oracle".active=true
at runtime makes only the Oracle datasource available.
Custom configuration profiles simplify this setup. By appending the following profile-specific configuration to the one above, you can select a persistence unit or datasource at runtime by setting quarkus.profile
. For example, use quarkus.profile=prod,pg
or quarkus.profile=prod,oracle
.
With this setup, ensure that only the active datasource is accessed. To achieve this, inject an InjectableInstance<DataSource>
or InjectableInstance<Pool>
with an @Any
qualifier and call getActive()
.
Alternatively, you can define a CDI bean producer for the default datasource. This bean producer redirects to the currently active named datasource. This allows it to be injected directly, as shown below:
- 1
- Do not inject a
DataSource
orAgroalDatasource
directly. Injecting inactive beans causes a startup failure. Instead, injectInjectableInstance<DataSource>
orInjectableInstance<AgroalDataSource>
. - 2
- Declare a CDI producer method to define the default datasource. It selects either PostgreSQL or Oracle, depending on which one is active.
- 3 4
- Check if a bean is active before retrieving it.
- 5
- Injects the only active datasource.
1.2.4. Use multiple datasources in a single transaction 링크 복사링크가 클립보드에 복사되었습니다!
By default, XA support on datasources is disabled. Therefore, a transaction may include no more than one datasource. Attempting to access multiple non-XA datasources in the same transaction results in an exception similar to the following:
To allow using multiple JDBC datasources in the same transaction:
- Make sure your JDBC driver supports XA. All supported JDBC drivers do, but other JDBC drivers might not.
- Make sure your database server is configured to enable XA.
-
Enable XA support explicitly for each relevant datasource by setting
quarkus.datasource[.optional name].jdbc.transactions
toxa
.
Using XA, a rollback in one datasource will trigger a rollback in every other datasource enrolled in the transaction.
XA transactions on reactive datasources are not supported at the moment.
If your transaction involves non-datasource resources, be aware that they might not support XA transactions or might require additional configuration.
If XA cannot be enabled for one of your datasources:
- Be aware that enabling XA for all datasources except one (and only one) is still supported through Last Resource Commit Optimization (LRCO).
-
If you do not need a rollback for one datasource to trigger a rollback for other datasources, consider splitting your code into multiple transactions. To do so, use
QuarkusTransaction.requiringNew()
/@Transactional(REQUIRES_NEW)
(preferably) orUserTransaction
(for more complex use cases).
If no other solution works and compatibility with Quarkus 3.8 or earlier is required, set quarkus.transaction-manager.unsafe-multiple-last-resources
to allow
to enable unsafe transaction handling across multiple non-XA datasources.
With this property set to allow
, a transaction rollback might only apply to the last non-XA datasource, while other non-XA datasources may have already committed their changes. This can leave the system in an inconsistent state.
Alternatively, allow the same unsafe behavior but with warnings when it occurs:
-
Setting the property to
warn-each
logs a warning for each offending transaction. -
Setting the property to
warn-first
logs a warning for the first offending transaction.
We do not recommend using this configuration property and plan to remove it in the future. You should update your application accordingly. If you believe your use case justifies keeping this option, open an issue in the Quarkus tracker explaining why.
1.3. Datasource integrations 링크 복사링크가 클립보드에 복사되었습니다!
1.3.1. Datasource health check 링크 복사링크가 클립보드에 복사되었습니다!
If you use the quarkus-smallrye-health
extension, the quarkus-agroal
and reactive client extensions automatically add a readiness health check to validate the datasource.
When you access your application’s health readiness endpoint, /q/health/ready
by default, you receive information about the datasource validation status. If you have multiple datasources, all datasources are checked, and if a single datasource validation failure occurs, the status changes to DOWN
.
This behavior can be disabled by using the quarkus.datasource.health.enabled
property.
To exclude only a particular datasource from the health check:
quarkus.datasource."datasource-name".health-exclude=true
quarkus.datasource."datasource-name".health-exclude=true
1.3.2. Datasource metrics 링크 복사링크가 클립보드에 복사되었습니다!
If you are using the quarkus-micrometer
or quarkus-smallrye-metrics
extension, quarkus-agroal
can contribute some datasource-related metrics to the metric registry. This can be activated by setting the quarkus.datasource.metrics.enabled
property to true
.
For the exposed metrics to contain any actual values, a metric collection must be enabled internally by the Agroal mechanisms. By default, this metric collection mechanism is enabled for all datasources when a metrics extension is present, and metrics for the Agroal extension are enabled.
To disable metrics for a particular datasource, set quarkus.datasource.jdbc.enable-metrics
to false
, or apply quarkus.datasource.<datasource name>.jdbc.enable-metrics
for a named datasource. This disables collecting the metrics and exposing them in the /q/metrics
endpoint if the mechanism to collect them is disabled.
Conversely, setting quarkus.datasource.jdbc.enable-metrics
to true
, or quarkus.datasource.<datasource name>.jdbc.enable-metrics
for a named datasource explicitly enables metrics collection even if a metrics extension is not in use. This can be useful if you need to access the collected metrics programmatically. They are available after calling dataSource.getMetrics()
on an injected AgroalDataSource
instance.
If the metrics collection for this datasource is disabled, all values result in zero.
1.3.3. Datasource tracing 링크 복사링크가 클립보드에 복사되었습니다!
To use tracing with a datasource, you need to add the quarkus-opentelemetry
extension to your project.
You do not need to declare a different driver to enable tracing. If you use a JDBC driver, you need to follow the instructions in the OpenTelemetry extension.
Even with all the tracing infrastructure in place, the datasource tracing is not enabled by default, and you need to enable it by setting this property:
enable tracing
# enable tracing
quarkus.datasource.jdbc.telemetry=true
1.3.4. Narayana transaction manager integration 링크 복사링크가 클립보드에 복사되었습니다!
Integration is automatic if the Narayana JTA extension is also available.
You can override this by setting the transactions
configuration property:
-
quarkus.datasource.jdbc.transactions
for default unnamed datasource -
quarkus.datasource.<datasource-name>.jdbc.transactions
for named datasource
For more information, see the Configuration reference section below.
To facilitate the storage of transaction logs in a database by using JDBC, see Configuring transaction logs to be stored in a datasource section of the Using transactions in Quarkus guide.
1.3.4.1. Named datasources 링크 복사링크가 클립보드에 복사되었습니다!
When using Dev Services, the default datasource will always be created, but to specify a named datasource, you need to have at least one build time property so Quarkus can detect how to create the datasource.
You will usually specify the db-kind
property or explicitly enable Dev Services by setting quarkus.datasource."name".devservices.enabled=true
.
1.3.5. Testing with in-memory databases 링크 복사링크가 클립보드에 복사되었습니다!
Some databases like H2 and Derby are commonly used in the embedded mode as a facility to run integration tests quickly.
The recommended approach is to use the database intended for production to get results as close as possible to a production environment. This is made easier by Dev Services because they require no configuration and start relatively quickly. However, it is also possible to use JVM-powered databases for scenarios when the ability to run simple integration tests is required.
1.3.5.1. Support and limitations 링크 복사링크가 클립보드에 복사되었습니다!
Embedded databases (H2 and Derby) work in JVM mode. For native mode, the following limitations apply:
- Derby cannot be embedded into the application in native mode. However, the Quarkus Derby extension allows native compilation of the Derby JDBC client, supporting remote connections.
- Embedding H2 within your native image is not recommended. Consider using an alternative approach, for example, using a remote connection to a separate database instead.
1.4. References 링크 복사링크가 클립보드에 복사되었습니다!
1.4.1. Common datasource configuration reference 링크 복사링크가 클립보드에 복사되었습니다!
🔒 Fixed at build time - Configuration property fixed at build time - All other configuration properties are overridable at runtime
Configuration property | Type | Default |
🔒 Fixed at build time 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: | boolean |
|
🔒 Fixed at build time 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: | boolean |
|
🔒 Fixed at build time
The kind of database we will connect to (e.g. h2, postgresql…).
Environment variable: | string | |
🔒 Fixed at build time
The version of the database we will connect to (e.g. '10.0'). Important
The version number set here should follow the same numbering scheme as the string returned by 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: | string | |
🔒 Fixed at build time
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: | boolean |
|
Whether this datasource should be active at runtime. See this section of the documentation.
Environment variable: | boolean |
|
The datasource username
Environment variable: | string | |
The datasource password
Environment variable: | string | |
The credentials provider name
Environment variable: | string | |
The credentials provider bean name.
This is a bean name (as in
For Vault, the credentials provider bean name is
Environment variable: | string | |
Type | Default | |
🔒 Fixed at build time
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: | boolean | |
🔒 Fixed at build time
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: | string | |
🔒 Fixed at build time
Environment variables that are passed to the container.
Environment variable: | Map<String,String> | |
🔒 Fixed at build time
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: | Map<String,String> | |
🔒 Fixed at build time
Generic properties that are added to the database connection URL.
Environment variable: | Map<String,String> | |
🔒 Fixed at build time
Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.
Environment variable: | int | |
🔒 Fixed at build time
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: | string | |
🔒 Fixed at build time
The database name to use if this Dev Service supports overriding it.
Environment variable: | string | |
🔒 Fixed at build time
The username to use if this Dev Service supports overriding it.
Environment variable: | string | |
🔒 Fixed at build time
The password to use if this Dev Service supports overriding it.
Environment variable: | string | |
🔒 Fixed at build time
The paths to SQL scripts 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: | list of string | |
🔒 Fixed at build time
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: | Map<String,String> | |
🔒 Fixed at build time
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. Warning
This feature needs to be enabled explicitly in
This configuration property is set to
Environment variable: | boolean |
|
🔒 Fixed at build time
Whether the logs should be consumed by the JBoss logger. This has no effect if the provider is not a container-based database, such as H2 or Derby.
Environment variable: | boolean |
|
1.4.2. JDBC configuration reference 링크 복사링크가 클립보드에 복사되었습니다!
🔒 Fixed at build time - Configuration property fixed at build time - All other configuration properties are overridable at runtime
Configuration property | Type | Default |
🔒 Fixed at build time Activate or disable the dev ui page.
Environment variable: | boolean |
|
🔒 Fixed at build time Allow sql queries in the Dev UI page
Environment variable: | boolean |
|
🔒 Fixed at build time Append this to the select done to fetch the table values. eg: LIMIT 100 or TOP 100
Environment variable: | string | |
🔒 Fixed at build time
Allowed database host. By default, only localhost is allowed. Any provided host here will also be allowed. You can use the special value
Environment variable: | string | |
🔒 Fixed at build time
If we create a JDBC datasource for this datasource.
Environment variable: | boolean |
|
🔒 Fixed at build time
The datasource driver class name
Environment variable: | string | |
🔒 Fixed at build time
Whether we want to use regular JDBC transactions, XA, or disable all transactional capabilities.
When enabling XA you will need a driver implementing
Environment variable: | enabled: Integrate the JDBC Datasource with the JTA TransactionManager of Quarkus. This is the default.
xa: Similarly to disabled: Disables the Agroal integration with the Narayana TransactionManager. This is typically a bad idea, and is only useful in special cases: make sure to not use this without having a deep understanding of the implications. | enabled |
🔒 Fixed at build time
Enable datasource metrics collection. If unspecified, collecting metrics will be enabled by default if a metrics extension is active.
Environment variable: | boolean | |
🔒 Fixed at build time
Enable OpenTelemetry JDBC instrumentation.
Environment variable: | boolean |
|
The datasource URL
Environment variable: | 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: | int | |
The datasource pool minimum size
Environment variable: | int |
|
The datasource pool maximum size
Environment variable: | int |
|
The interval at which we validate idle connections in the background.
Set to
Environment variable: |
| |
Perform foreground validation on connections that have been idle for longer than the specified interval.
Environment variable: | ||
The timeout before cancelling the acquisition of a new connection
Environment variable: |
| |
The interval at which we check for connection leaks.
Environment variable: |
| |
The interval at which we try to remove idle connections.
Environment variable: |
| |
The max lifetime of a connection.
Environment variable: |
| |
The transaction isolation level.
Environment variable: |
| |
Collect and display extra troubleshooting info on leaked connections.
Environment variable: | boolean |
|
Allows connections to be flushed upon return to the pool. It’s not enabled by default.
Environment variable: | boolean |
|
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: | boolean |
|
Query executed when first using a connection.
Environment variable: | string | |
Query executed to validate a connection.
Environment variable: | string | |
Forces connection validation prior to acquisition (foreground validation) regardless of the idle status.
Because of the overhead of performing validation on every call, it’s recommended to rely on default idle validation instead, and to leave this to
Environment variable: | boolean |
|
Disable pooling to prevent reuse of Connections. Use this when an external pool manages the life-cycle of Connections.
Environment variable: | boolean |
|
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: |
| |
Other unspecified properties to be passed to the JDBC driver when creating new connections.
Environment variable: | Map<String,String> | |
Enable OpenTelemetry JDBC instrumentation.
Environment variable: | boolean |
|
To write duration values, use the standard java.time.Duration
format. See the Duration#parse() Java API documentation for more information.
You can also use a simplified format, starting with a number:
- If the value is only a number, it represents time in seconds.
-
If the value is a number followed by
ms
, it represents time in milliseconds.
In other cases, the simplified format is translated to the java.time.Duration
format for parsing:
-
If the value is a number followed by
h
,m
, ors
, it is prefixed withPT
. -
If the value is a number followed by
d
, it is prefixed withP
.
1.4.3. JDBC URL reference 링크 복사링크가 클립보드에 복사되었습니다!
Each of the supported databases contains different JDBC URL configuration options. The following section gives an overview of each database URL and a link to the official documentation.
1.4.3.1. DB2 링크 복사링크가 클립보드에 복사되었습니다!
jdbc:db2://<serverName>[:<portNumber>]/<databaseName>[:<key1>=<value>;[<key2>=<value2>;]]
- Example
-
jdbc:db2://localhost:50000/MYDB:user=dbadm;password=dbadm;
For more information on URL syntax and additional supported options, see the official documentation.
1.4.3.2. Derby 링크 복사링크가 클립보드에 복사되었습니다!
jdbc:derby:[//serverName[:portNumber]/][memory:]databaseName[;property=value[;property=value]]
- Example
-
jdbc:derby://localhost:1527/myDB
,jdbc:derby:memory:myDB;create=true
Derby is an embedded database that can run as a server, based on a file, or can run completely in memory. All of these options are available as listed above.
For more information, see the official documentation.
1.4.3.3. H2 링크 복사링크가 클립보드에 복사되었습니다!
jdbc:h2:{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value…]
- Example
-
jdbc:h2:tcp://localhost/~/test
,jdbc:h2:mem:myDB
H2 is a database that can run in embedded or server mode. It can use a file storage or run entirely in memory. All of these options are available as listed above.
For more information, see the official documentation.
1.4.3.4. 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))]
- Example
-
jdbc:mariadb://localhost:3306/test
For more information, see the official documentation.
1.4.3.5. Microsoft SQL server 링크 복사링크가 클립보드에 복사되었습니다!
jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]
- Example
-
jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks
The Microsoft SQL Server JDBC driver works essentially the same as the others.
For more information, see the official documentation.
1.4.3.6. 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))]
- Example
-
jdbc:mysql://localhost:3306/test
For more information, see the official documentation.
1.4.3.6.1. MySQL limitations 링크 복사링크가 클립보드에 복사되었습니다!
When compiling a Quarkus application to a native image, the MySQL support for JMX and Oracle Cloud Infrastructure (OCI) integrations are disabled as they are incompatible with GraalVM native images.
- The lack of JMX support is a natural consequence of running in native mode and is unlikely to be resolved.
- The integration with OCI is not supported.
1.4.3.7. Oracle 링크 복사링크가 클립보드에 복사되었습니다!
jdbc:oracle:driver_type:@database_specifier
- Example
-
jdbc:oracle:thin:@localhost:1521/ORCL_SVC
For more information, see the official documentation.
1.4.3.8. PostgreSQL 링크 복사링크가 클립보드에 복사되었습니다!
jdbc:postgresql:[//][host][:port][/database][?key=value…]
- Example
-
jdbc:postgresql://localhost/test
The defaults for the different parts are as follows:
host
- localhost
port
- 5432
database
- same name as the username
For more information about additional parameters, see the official documentation.
1.4.4. Quarkus extensions and database drivers reference 링크 복사링크가 클립보드에 복사되었습니다!
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.
Database kind | Quarkus extension | Drivers |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Database kind | Quarkus extension | Driver |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
This automatic resolution is applicable in most cases so that driver configuration is not needed.
1.4.5. Reactive datasource configuration reference 링크 복사링크가 클립보드에 복사되었습니다!
🔒 Fixed at build time - Configuration property fixed at build time - All other configuration properties are overridable at runtime
Configuration property | Type | Default |
🔒 Fixed at build time
If we create a Reactive datasource for this datasource.
Environment variable: | boolean |
|
Whether prepared statements should be cached on the client side.
Environment variable: | boolean |
|
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: | list of string | |
The datasource pool maximum size.
Environment variable: | int |
|
When a new connection object is created, the pool assigns it an event loop.
When
Environment variable: | int | |
Whether all server certificates should be trusted.
Environment variable: | boolean |
|
PEM Trust config is disabled by default.
Environment variable: | boolean |
|
Comma-separated list of the trust certificate files (Pem format).
Environment variable: | list of string | |
JKS config is disabled by default.
Environment variable: | boolean |
|
Path of the key file (JKS format).
Environment variable: | string | |
Password of the key file.
Environment variable: | string | |
PFX config is disabled by default.
Environment variable: | boolean |
|
Path to the key file (PFX format).
Environment variable: | string | |
Password of the key.
Environment variable: | string | |
PEM Key/cert config is disabled by default.
Environment variable: | boolean |
|
Comma-separated list of the path to the key files (Pem format).
Environment variable: | list of string | |
Comma-separated list of the path to the certificate files (Pem format).
Environment variable: | list of string | |
JKS config is disabled by default.
Environment variable: | boolean |
|
Path of the key file (JKS format).
Environment variable: | string | |
Password of the key file.
Environment variable: | string | |
PFX config is disabled by default.
Environment variable: | boolean |
|
Path to the key file (PFX format).
Environment variable: | string | |
Password of the key.
Environment variable: | string | |
The number of reconnection attempts when a pooled connection cannot be established on first try.
Environment variable: | int |
|
The interval between reconnection attempts when a pooled connection cannot be established on first try.
Environment variable: |
| |
The hostname verification algorithm to use in case the server’s identity should be checked. Should be
Environment variable: | string |
|
The maximum time a connection remains unused in the pool before it is closed.
Environment variable: |
| |
The maximum time a connection remains in the pool, after which it will be closed upon return and replaced as necessary.
Environment variable: |
| |
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
Environment variable: | boolean |
|
Set the pool name, used when the pool is shared among datasources, otherwise ignored.
Environment variable: | string | |
Other unspecified properties to be passed through the Reactive SQL Client directly to the database when new connections are initiated.
Environment variable: | Map<String,String> |
To write duration values, use the standard java.time.Duration
format. See the Duration#parse() Java API documentation for more information.
You can also use a simplified format, starting with a number:
- If the value is only a number, it represents time in seconds.
-
If the value is a number followed by
ms
, it represents time in milliseconds.
In other cases, the simplified format is translated to the java.time.Duration
format for parsing:
-
If the value is a number followed by
h
,m
, ors
, it is prefixed withPT
. -
If the value is a number followed by
d
, it is prefixed withP
.
1.4.5.1. Reactive MariaDB/MySQL specific configuration 링크 복사링크가 클립보드에 복사되었습니다!
🔒 Fixed at build time - Configuration property fixed at build time - All other configuration properties are overridable at runtime
Configuration property | Type | Default |
Type | Default | |
Charset for connections.
Environment variable: | string | |
Collation for connections.
Environment variable: | string | |
Desired security state of the connection to the server.
Environment variable: |
|
|
Connection timeout in seconds
Environment variable: | 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: |
|
|
The maximum number of inflight database commands that can be pipelined. By default, pipelining is disabled.
Environment variable: | 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: | boolean |
|
1.4.5.2. Reactive Microsoft SQL server-specific configuration 링크 복사링크가 클립보드에 복사되었습니다!
🔒 Fixed at build time - Configuration property fixed at build time - All other configuration properties are overridable at runtime
Configuration property | Type | Default |
Type | Default | |
The desired size (in bytes) for TDS packets.
Environment variable: | int | |
Whether SSL/TLS is enabled.
Environment variable: | boolean |
|
1.4.5.3. Reactive Oracle-specific configuration 링크 복사링크가 클립보드에 복사되었습니다!
🔒 Fixed at build time - Configuration property fixed at build time - All other configuration properties are overridable at runtime
Configuration property | Type | Default |
No configuration properties found. |
1.4.5.4. Reactive PostgreSQL-specific configuration 링크 복사링크가 클립보드에 복사되었습니다!
🔒 Fixed at build time - Configuration property fixed at build time - All other configuration properties are overridable at runtime
Configuration property | Type | Default |
Type | Default | |
The maximum number of inflight database commands that can be pipelined.
Environment variable: | int | |
SSL operating mode of the client. See Protection Provided in Different Modes.
Environment variable: |
|
|
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: | boolean |
|
1.4.6. Reactive datasource URL reference 링크 복사링크가 클립보드에 복사되었습니다!
1.4.6.1. DB2 링크 복사링크가 클립보드에 복사되었습니다!
db2://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]
- Example
-
db2://dbuser:secretpassword@database.server.com:50000/mydb
Currently, the client supports the following parameter keys:
-
host
-
port
-
user
-
password
-
database
Configuring parameters in the connection URL overrides the default properties.
1.4.6.2. Microsoft SQL server 링크 복사링크가 클립보드에 복사되었습니다!
sqlserver://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]
- Example
-
sqlserver://dbuser:secretpassword@database.server.com:1433/mydb
Currently, the client supports the following parameter keys:
-
host
-
port
-
user
-
password
-
database
Configuring parameters in the connection URL overrides the default properties.
1.4.6.3. MySQL / MariaDB 링크 복사링크가 클립보드에 복사되었습니다!
mysql://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]
- Example
-
mysql://dbuser:secretpassword@database.server.com:3211/mydb
Currently, the client supports the following parameter keys (case-insensitive):
-
host
-
port
-
user
-
password
-
schema
-
socket
-
useAffectedRows
Configuring parameters in the connection URL overrides the default properties.
1.4.6.4. Oracle 링크 복사링크가 클립보드에 복사되었습니다!
1.4.6.4.1. EZConnect format 링크 복사링크가 클립보드에 복사되었습니다!
oracle:thin:@[[protocol:]//]host[:port][/service_name][:server_mode][/instance_name][?connection properties]
- Example
-
oracle:thin:@mydbhost1:5521/mydbservice?connect_timeout=10sec
1.4.6.4.2. TNS alias format 링크 복사링크가 클립보드에 복사되었습니다!
oracle:thin:@<alias_name>[?connection properties]
- Example
-
oracle:thin:@prod_db?TNS_ADMIN=/work/tns/
1.4.6.5. PostgreSQL 링크 복사링크가 클립보드에 복사되었습니다!
postgresql://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]
- Example
-
postgresql://dbuser:secretpassword@database.server.com:5432/mydb
Currently, the client supports:
Following parameter keys:
-
host
-
port
-
user
-
password
-
dbname
-
sslmode
-
Additional properties, such as:
-
application_name
-
fallback_application_name
-
search_path
-
options
-
Configuring parameters in the connection URL overrides the default properties.