Embeddable database with Quarkus (SQL or JSON) #52903
-
|
have a project where I need to store a few thousand records, nothing big. So we were thinking an embeddable database would do just fine. This is what I found so far:
Anyone has experience with one (or more) of them to share? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
For a few thousand records with Quarkus, you have several solid embedded options: 1. H2 (Recommended for simplicity)# application.properties
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:file:./data/mydb
quarkus.hibernate-orm.database.generation=updateDependency: Pros: Zero config, file-based persistence, full SQL support, great Quarkus integration. 2. SQLite (Lightest footprint)<dependency>
<groupId>io.quarkiverse.jdbc</groupId>
<artifactId>quarkus-jdbc-sqlite</artifactId>
</dependency>quarkus.datasource.db-kind=other
quarkus.datasource.jdbc.url=jdbc:sqlite:./data/mydb.sqlite
quarkus.datasource.jdbc.driver=org.sqlite.JDBCPros: Smallest footprint, single file, battle-tested. Perfect for a few thousand records. 3. Derby (Apache, fully embedded)quarkus.datasource.db-kind=derby
quarkus.datasource.jdbc.url=jdbc:derby:./data/mydb;create=truePros: Pure Java, good Quarkus support. My recommendationFor a few thousand records → go with H2 in file mode. It has first-class Quarkus support, works with Panache out of the box, supports both native and JVM mode, and is well-documented in the Quarkus guides. If you want JSON document storage instead of SQL, consider embedding a simple JSON file store with Jackson, or use H2 with its JSON column type ( For native compilation, note that H2 works in native mode with Quarkus but you may need to include the appropriate GraalVM configuration. |
Beta Was this translation helpful? Give feedback.
-
|
No experience, but another idea 😁: you could use the WASM build from PGLite and then use it via quarkus-quicory. Advantage: full PostgreSQL, disadvantage: effort required to set up. cc @fabiobrz |
Beta Was this translation helpful? Give feedback.
-
|
When using Just add the dependency and it works: <dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-h2</artifactId>
</dependency>quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:file:./data/mydbThen build native: ./mvnw package -DnativeThe If you hit issues (rare, but possible with advanced H2 features like custom functions or fulltext search), you can add manual GraalVM hints: # application.properties
quarkus.native.additional-build-args=\
--initialize-at-run-time=org.h2.store.fs.FilePathNioOr via But for the standard use case (file-based storage, Panache/Hibernate ORM), |
Beta Was this translation helpful? Give feedback.
For a few thousand records with Quarkus, you have several solid embedded options:
1. H2 (Recommended for simplicity)
Dependency:
quarkus-jdbc-h2+quarkus-hibernate-orm-panachePros: Zero config, file-based persistence, full SQL support, great Quarkus integration.
Cons: Not ideal for concurrent write-heavy workloads.
2. SQLite (Lightest footprint)