Exposed offers JDBC and R2DBC database access for Kotlin through a typesafe query DSL and an optional DAO layer across major SQL engines.
Overview
Exposed is a lightweight Kotlin SQL library that sits above JDBC or R2DBC drivers. Teams can express queries with a typesafe domain-specific language or map tables to objects through a Data Access Object API, switching styles within one project when needed.
Core modules split responsibilities: exposed-core hosts DSL primitives, exposed-jdbc and exposed-r2dbc provide transport implementations, and exposed-dao layers optional ORM helpers (with an experimental R2DBC DAO module). Extension modules add JSON columns, encrypted fields, JavaMoney types, schema migration helpers, and Spring transaction integration.
The project supports H2, PostgreSQL, MySQL, SQLite, Oracle, and other engines, aiming to reduce lock-in when swapping databases. Spring Boot and Ktor integrations are documented for framework users, and JetBrains maintains the library for its own products.
Migrations can be managed through dedicated JDBC or R2DBC migration modules built on shared core logic. Requirements vary by module, with newer Spring integrations expecting newer JDK releases while most modules remain compatible with older Java versions.
Key features
- Typesafe SQL DSL queries
- Optional DAO object mapping
- JDBC and R2DBC driver support
- JSON and encrypted column types
- Schema migration helper modules
- Spring transaction integration
- Multi-database engine compatibility
- Spring Boot and Ktor support
Use cases
- Kotlin server database access
- Type-safe reporting queries
- ORM-style CRUD in Kotlin apps
- Reactive R2DBC data layers
- Portable SQL across databases