Skip to content

About

JDBC database services for Java OSGi and Apache Karaf, with transaction management and plugin migrations.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

DrRemote DB

Build License: Apache-2.0

PostgreSQL, SQLite, and DuckDB services for modular Java applications running in OSGi / Apache Karaf. Each database bundle exposes a pooled JDBC data source, transactions, parameterized queries, and versioned plugin migrations through OSGi Declarative Services.

Database Typical use Migration support
PostgreSQL Applications using a database server Per-plugin schemas, JDBC and psql scripts, readiness services
SQLite Embedded applications and local storage Single statements, atomic batches, baselines, readiness services
DuckDB Embedded analytical workloads Explicit single-statement migrations

Version: 1.1.0. Build from source or use the binary release installation guide. Its artifacts are not published to Maven Central, and the former public DrRemote Maven repository is no longer available. Third-party dependencies come from Maven Central; no private server or account is required.

Requirements

  • JDK 17 or later; CI checks Java 17 and 21.
  • Maven 3.9 or later.
  • Apache Karaf 4.4.11 for the supplied features, or an OSGi runtime with Declarative Services, ConfigAdmin, and the required JDBC/HikariCP bundles.
  • PostgreSQL only: an existing database and database user. Install psql on the runtime host if you use script migrations.

SQLite and DuckDB use embedded native JDBC drivers. Native platform support follows the selected driver versions.

Build

git clone https://github.com/DoctorRemoteControl/drremote-db-postgresql-sqlite.git
cd drremote-db-postgresql-sqlite
mvn clean install

This runs the tests, builds the bundles and Karaf feature XML, checks the features' OSGi dependency resolution, and installs the project artifacts into your local Maven repository (normally ~/.m2/repository). It does not publish them to a server.

For validation without installation, use mvn clean verify. CI also uploads bundles, source/Javadoc JARs, feature descriptors, and test reports as workflow artifacts.

Quick start: SQLite in Karaf

  1. Build with mvn clean install as above.

  2. Copy the SQLite configuration to your Karaf installation:

    cp examples/de.drremote.db.sqlite.cfg.example "$KARAF_HOME/etc/de.drremote.db.sqlite.cfg"
  3. In the Karaf console, install the feature:

    feature:repo-add mvn:de.drremote.db/sqlite-features/1.1.0/xml/features
    feature:install de.drremote-db-sqlite
    service:list de.drremote.db.sqlite.api.DbCore
    

The example database is stored at ${karaf.data}/drremote.sqlite. Karaf must run as the same user as Maven, or have its Maven resolver's local repository configured to the repository used for mvn install. See Karaf installation and troubleshooting.

PostgreSQL ScriptMigration deliberately uses an installed psql client for complex scripts and client meta-commands. This remains a supported migration path; see PostgreSQL usage.

Try a client bundle

The notes example contains a real migration descriptor and repository service:

mvn -f examples/notes-client/pom.xml clean package

Then install its JAR in the Karaf console, replacing the path with your checkout's absolute path:

bundle:install -s file:/absolute/path/to/drremote-db-postgresql-sqlite/examples/notes-client/target/notes-client-1.1.0.jar
service:list example.notes.NotesRepository

The migration registry creates the notes table and publishes a DatabaseReady service. The repository waits for that service before activation. Read the SQLite usage guide for queries, transaction behavior, batches, and baselines.

Optional JSON support

Use the separate JSON adapter inside any existing transaction callback:

ArrayNode rows = transactions.inTransaction(db -> JsonQueries.on(db.getConnection())
    .withJsonColumns("payload")
    .query("SELECT id, payload FROM settings WHERE id = ?", id));

It converts result rows to JSON and binds JsonNode / JsonValue parameters, including PostgreSQL JSONB and SQLite/DuckDB JSON storage. Existing database cores keep their current APIs and have no Jackson dependency. Install the optional de.drremote-db-json feature when using it in Karaf.

See the JSON guide and buildable JSON client.

Other databases

Database Example configuration Karaf feature repository Feature
PostgreSQL Configuration mvn:de.drremote.db/postgresql-features/1.1.0/xml/features de.drremote-db-postgresql
DuckDB Configuration mvn:de.drremote.db/duckdb-features/1.1.0/xml/features de.drremote-db-duckdb

Copy the appropriate configuration to $KARAF_HOME/etc/, removing the .example suffix, and replace PostgreSQL placeholders before installing its feature.

Maven coordinates

All entries below use version 1.1.0, after building and installing from source:

Group Bundle artifact Feature artifact Java API package
de.drremote.db postgresql postgresql-features de.drremote.db.postgresql.api
de.drremote.db sqlite sqlite-features de.drremote.db.sqlite.api
de.drremote.db duckdb duckdb-features de.drremote.db.duckdb.api

Use a provided dependency in an OSGi client; the runtime installs the database bundle and its dependencies. The example POM shows a complete client build. These libraries are OSGi services, rather than standalone database servers or a command-line application.

Documentation

The project is in active development. Test upgrades against your own schema and workloads before using them with existing data. Licensed under Apache-2.0.

About

JDBC database services for Java OSGi and Apache Karaf, with transaction management and plugin migrations.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages