This blog post describes the way I switch between different database
systems (in my case: switch between derby and PostgreSQL) in apache
karaf:
https://steinar.bang.priv.no/2019/10/26/pluggable-databases-for-apache-karaf-applications/
What I do, is:
1. Create an application specific DatabaseService interface
2. Inject the application specific DatabaseService into the business
logic DS component
3. Create an OSGi bundle defining a liquibase schema
4. Create a DS component providing the DatabaseService that starts
derby in-memory database and install the liquibase schema
5. Create a DS component providing the DatabaseService that connects to
PostgreSQL and install the liquibase schema
6. Create different karaf features that
1. load the application with the derby DS component
2. load the application with the PostgreSQL component
More detail and examples in the blog post.