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.
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.
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.
Tip
|
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.
-
Add the correct JDBC extension for the database of your choice.
-
quarkus-jdbc-db2
-
quarkus-jdbc-derby
-
quarkus-jdbc-h2
-
quarkus-jdbc-mariadb
-
quarkus-jdbc-mssql
-
quarkus-jdbc-mysql
-
quarkus-jdbc-oracle
-
quarkus-jdbc-postgresql
-
-
Configure your JDBC datasource:
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
-
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.
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.
-
Add the correct reactive extension for the database of your choice.
-
quarkus-reactive-db2-client
-
quarkus-reactive-mssql-client
-
quarkus-reactive-mysql-client
-
quarkus-reactive-oracle-client
-
quarkus-reactive-pg-client
-
-
Configure your reactive datasource:
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
-
This configuration value is only required if there is more than one Reactive driver extension on the classpath.
-
The following section describes the configuration for single or multiple datasources. For simplicity, we will reference a single datasource as the default (unnamed) 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 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
-
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.
-
-
Configure the following properties to define credentials:
quarkus.datasource.username=<your username> quarkus.datasource.password=<your password>
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.
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
-
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
-
Other JDBC extensions, such as SQLite and its documentation, can be found in the Quarkiverse.
For example, to add the PostgreSQL driver dependency:
./mvnw quarkus:add-extension -Dextensions="jdbc-postgresql"
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"
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
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.
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.
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.
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;
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.
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.
Quarkus offers several reactive clients for use with a reactive datasource.
-
Add the corresponding extension to your application:
-
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
The installed extension must be consistent with the
quarkus.datasource.db-kind
you define in your datasource configuration.
-
-
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
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.
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.
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
-
To disable the reactive datasource explicitly:
quarkus.datasource.reactive=false
TipIn most cases, the configuration above will be optional as either a JDBC driver or a reactive datasource extension will be present, not both.
Note
|
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:
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
Notice there is an extra section in the configuration property.
The syntax is as follows: quarkus.datasource.[optional name.][datasource property]
.
Note
|
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.
|
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:
@Inject
AgroalDataSource defaultDataSource;
@Inject
@DataSource("users")
AgroalDataSource usersDataSource;
@Inject
@DataSource("inventory")
AgroalDataSource inventoryDataSource;
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.
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
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.
Tip
|
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 %pg.quarkus.hibernate-orm."pg".active=true
%pg.quarkus.datasource."pg".active=true
# Add any PostgreSQL-related runtime configuration here, prefixed with "%pg."
%oracle.quarkus.hibernate-orm."oracle".active=true
%oracle.quarkus.datasource."oracle".active=true
# Add any Oracle-related runtime configuration here, prefixed with "%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()
.
import io.quarkus.arc.InjectableInstance;
@ApplicationScoped
public class MyConsumer {
@Inject
@Any
InjectableInstance<DataSource> dataSource;
public void doSomething() {
DataSource activeDataSource = dataSource.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:
public class MyProducer {
@Inject
@DataSource("pg")
InjectableInstance<DataSource> pgDataSourceBean; // (1)
@Inject
@DataSource("oracle")
InjectableInstance<DataSource> oracleDataSourceBean;
@Produces // (2)
@ApplicationScoped
public DataSource dataSource() {
if (pgDataSourceBean.getHandle().getBean().isActive()) { // (3)
return pgDataSourceBean.get();
} else if (oracleDataSourceBean.getHandle().getBean().isActive()) { // (3)
return oracleDataSourceBean.get();
} else {
throw new RuntimeException("No active datasource!");
}
}
}
@ApplicationScoped
public class MyConsumer {
@Inject
DataSource dataSource; // (4)
public void doSomething() {
// .. just use the injected datasource ...
}
}
-
Do not inject a
DataSource
orAgroalDatasource
directly. Injecting inactive beans causes a startup failure. Instead, injectInjectableInstance<DataSource>
orInjectableInstance<AgroalDataSource>
. -
Declare a CDI producer method to define the default datasource. It selects either PostgreSQL or Oracle, depending on which one is active.
-
Check if a bean is active before retrieving it.
-
Injects the only active datasource.
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:
...
Caused by: java.sql.SQLException: Exception in association of connection to existing transaction
at io.agroal.narayana.NarayanaTransactionIntegration.associate(NarayanaTransactionIntegration.java:130)
...
Caused by: java.sql.SQLException: Failed to enlist. Check if a connection from another datasource is already enlisted to the same transaction
at io.agroal.narayana.NarayanaTransactionIntegration.associate(NarayanaTransactionIntegration.java:121)
...
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.
Note
|
XA transactions on reactive datasources are not supported at the moment. |
Note
|
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).
Caution
|
If no other solution works and compatibility with Quarkus 3.8 or earlier is required, set With this property set to Alternatively, allow the same unsafe behavior but with warnings when it occurs:
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. |
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
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.
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
quarkus.datasource.jdbc.telemetry=true
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
Datasources are also automatically registered with the transaction recovery system when recovery is enabled. Sometimes an application may wish to override this behaviour, such as when more than one datasource connects to the same database, by setting the configuration property quarkus.datasource.xa.jdbc.enable-recovery
to false
. Note that it is vital that at least one such XA capable datasource is enabled for recovery.
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.
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
.
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.
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.
-
Add a dependency on the artifacts providing the additional tools that are under the following Maven coordinates:
-
io.quarkus:quarkus-test-h2
for H2 -
io.quarkus:quarkus-test-derby
for DerbyThis will allow you to test your application even when it is compiled into a native executable while the database will run as a JVM process.
-
-
Add the following specific annotation on any class in your integration tests for running integration tests in both JVM or native executables:
-
@QuarkusTestResource(H2DatabaseTestResource.class)
-
@QuarkusTestResource(DerbyDatabaseTestResource.class)
This ensures that the test suite starts and terminates the managed database in a separate process as required for test execution.
H2 examplepackage my.app.integrationtests.db; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; @QuarkusTestResource(H2DatabaseTestResource.class) public class TestResources { }
-
-
Configure the connection to the managed database:
quarkus.datasource.db-kind=h2 quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test
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.
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.
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.
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.
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.
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.
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.
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.
jdbc:oracle:driver_type:@database_specifier
- Example
-
jdbc:oracle:thin:@localhost:1521/ORCL_SVC
For more information, see the official documentation.
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.
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 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tip
|
This automatic resolution is applicable in most cases so that driver configuration is not needed. |
db2://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]
- Example
-
db2://dbuser:[email protected]:50000/mydb
Currently, the client supports the following parameter keys:
-
host
-
port
-
user
-
password
-
database
Note
|
Configuring parameters in the connection URL overrides the default properties. |
sqlserver://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]
- Example
-
sqlserver://dbuser:[email protected]:1433/mydb
Currently, the client supports the following parameter keys:
-
host
-
port
-
user
-
password
-
database
Note
|
Configuring parameters in the connection URL overrides the default properties. |
mysql://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]
- Example
-
mysql://dbuser:[email protected]:3211/mydb
Currently, the client supports the following parameter keys (case-insensitive):
-
host
-
port
-
user
-
password
-
schema
-
socket
-
useAffectedRows
Note
|
Configuring parameters in the connection URL overrides the default properties. |
oracle:thin:@[[protocol:]//]host[:port][/service_name][:server_mode][/instance_name][?connection properties]
- Example
-
oracle:thin:@mydbhost1:5521/mydbservice?connect_timeout=10sec
postgresql://[user[:[password]]@]host[:port][/database][?<key1>=<value1>[&<key2>=<value2>]]
- Example
-
postgresql://dbuser:[email protected]: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
-
Note
|
Configuring parameters in the connection URL overrides the default properties. |