Exposed Ktor JDBC Adapter
Latest stable Based on Exposed release 2.0.0
JDBC-specific readiness and transaction helpers for applications that already depend on the backend-neutral Ktor core.
Problem
Section titled “Problem”Blocking JDBC must not run on a Ktor event-loop dispatcher, and a JDBC-only consumer should not receive R2DBC or cache classes.
When to use it
Section titled “When to use it”Use this adapter for a JDBC Database and an application-provided bounded blocking dispatcher.
Coordinates
Section titled “Coordinates”implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>"))implementation("io.github.bluetape4k.exposed:bluetape4k-exposed-ktor-jdbc")Core concepts
Section titled “Core concepts”exposedKtorJdbcReadinessProbe runs SELECT 1 in runInterruptible. Its statement timeout is the smaller of the configured timeout and the remaining shared readiness budget.
Quick start
Section titled “Quick start”val probe = exposedKtorJdbcReadinessProbe(database, jdbcDispatcher)route.bluetape4kExposedHealthRoutes(listOf(probe))API by task
Section titled “API by task”- Use
exposedKtorJdbcReadinessProbefor a caller-owned JDBC database. - Use
ApplicationCall.exposedJdbcTransactionfor blocking transactions. - Compose
bluetape4kExposedJdbcErrors()in the existingStatusPagesblock.
Recommended patterns
Section titled “Recommended patterns”Size the dispatcher to useful pool concurrency, keep transaction work bounded, and close the database/pool and dispatcher in the application lifecycle.
Integrations
Section titled “Integrations”Depend on bluetape4k-exposed-ktor-core and the Exposed JDBC module only. R2DBC and cache integrations are separate artifacts.
Configuration
Section titled “Configuration”The dispatcher is required for JDBC readiness and transactions. Query timeout values must be finite and positive; sub-second JDBC values use a one-second driver timeout minimum.
Failure modes
Section titled “Failure modes”Blocking work on the event loop, an exhausted dispatcher, or a driver that ignores interruption can delay a request. Database failures map to a fixed unavailable response and never expose SQL or causes.
Operations
Section titled “Operations”Observe readiness and transaction timers with the core metric registry. Keep pool, dispatcher, authentication, and shutdown ownership in application code.
Testing
Section titled “Testing”Test H2 first, then the repository’s PostgreSQL and MySQL Testcontainers paths. Include cancellation, statement timeout, and dispatcher-isolation cases.
Workshops
Section titled “Workshops”No selective JDBC workshop is published in this 2.0.0 release line.
Limitations
Section titled “Limitations”Driver support for statement cancellation and query timeout varies. The coroutine deadline is a request boundary, not a guarantee that a non-cooperative driver stops immediately.