Thursday, April 1, 2021

Using SQLite with Quarkus

Introduction

Is it possible to use SQLite with Hibernate and Quarkus?
Yes it is! But native build is currently not supported!

  1. Add library-dependencies to your Quarkus-Project

<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.34.0</version>
</dependency>
<dependency>
<groupId>com.github.gwenn</groupId>
<artifactId>sqlite-dialect</artifactId>
<version>0.1.2</version>
</dependency>

    2. Edit your application.properties

quarkus.datasource.db-kind = other
quarkus.datasource.jdbc.driver=org.sqlite.JDBC

quarkus.hibernate-orm.dialect=org.sqlite.hibernate.dialect.SQLiteDialect
quarkus.datasource.jdbc.url=jdbc:sqlite:./mydatabase.db
%dev.quarkus.datasource.jdbc.url=jdbc:sqlite::memory:
%test.quarkus.datasource.jdbc.url=jdbc:sqlite::memory:
%dev.quarkus.hibernate-orm.database.generation = drop-and-create



That's it!