Chapter 1. Introduction to using data sources with Quarkus


When you set the db-kind property in the configuration file of your application to match the type of your data source that you want to use, Quarkus automatically resolves the appropriate type of database driver. The following procedure demonstrates how you can set the db-kind property for a data source.

Prerequisites

  • You have a Quarkus Maven project.

Procedure

  1. Navigate to your Quarkus project directory.
  2. In the src/main/resources/application.properties file, set the value of the db-kind property to match the type of the data source that you want to use. The following example uses postgresql as the data source type:

    quarkus.datasource.db-kind=postgresql
    Copy to Clipboard Toggle word wrap

1.2. Setting database credentials

You can define credentials that your application uses to access your database. Defining access credentials for your database is optional. You can skip this procedure when configuring a data source for your application.

Prerequisites

  • You have a Quarkus Maven project.
  • You have set the db-kind property for your data source.
  • Your Quarkus application is in JVM mode. This prerequisite applies when you use a JDBC driver that Quarkus does not support in native mode.

Procedure

  1. Navigate to your Quarkus project directory.
  2. In the src/main/resources/application.properties file, set the value of the quarkus.datasource.username property to match the username that your application uses to access the database:

    quarkus.datasource.username=<username>
    Copy to Clipboard Toggle word wrap
  3. In the src/main/resources/application.properties file, set the value of the quarkus.datasource.password property to match the password that your application uses to access the database:

    quarkus.datasource.password=<password>
    Copy to Clipboard Toggle word wrap

The following table provides an overview of Quarkus built-in databases and the extensions that you can use to connect your application to a relational database:

Expand
Table 1.1. Driver extensions for Quarkus built-in databases
Database built-indb-kindAgroal extensionReactive extension

DB2

db2

quarkus-jdbc-db2

quarkus-reactive-db2-client

Derby

derby

quarkus-jdbc-derby

N/A

H2

h2

quarkus-jdbc-h2

N/A

MariaDB

mariadb

quarkus-jdbc-mariadb

quarkus-reactive-mysql-client

Microsoft SQL Server

mssql

quarkus-jdbc-mssql

N/A

MySQL

mysql

quarkus-jdbc-mysql

quarkus-reactive-mysql-client

PostgreSQL

postgresql, pgsql, or pg

quarkus-jdbc-postgresql

quarkus-reactive-pg-client

You can configure H2 and Derby databases to run in embedded mode. The H2 and Derby driver extensions do not support compiling the embedded database engine into native executables.

Important

This table includes supported and community artifacts. For a list of supported Maven artifacts, see the Red Hat build of Quarkus Component Details page.

When you use one of the built-in database kinds the JDBC driver resolves automatically to the following values:

Expand
Table 1.2. JDBC and XA drivers for Quarkus built-in databases
DatabaseJDBC driverXA driver

DB2

com.ibm.db2.jcc.DBDriver

com.ibm.db2.jcc.DB2XADataSource

Derby

org.apache.derby.jdbc.ClientDriver

org.apache.derby.jdbc.ClientXADataSource

H2

org.h2.Driver

org.h2.jdbcx.JdbcDataSource

MariaDB

org.mariadb.jdbc.Driver

org.mariadb.jdbc.MySQLDataSource

Microsoft SQL Server

com.microsoft.sqlserver.jdbc.SQLServerDriver

com.microsoft.sqlserver.jdbc.SQLServerXADataSource

MySQL

com.mysql.cj.jdbc.Driver

com.mysql.cj.jdbc.MysqlXADataSource

PostgreSQL

org.postgresql.Driver

org.postgresql.xa.PGXADataSource

Note

You can configure H2 and Derby databases to run in embedded mode. The H2 and Derby driver extensions do not support compiling the embedded database engine into native executables.

Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat
Back to top