← Back to Stormify Documentation

JdbcDataSource

class JdbcDataSource(jdbc: DataSource, initSql: String? = null) : DataSource

JDBC DataSource wrapper that implements KDBC DataSource interface.

initSql is a single SQL statement executed on every freshly opened connection before it is returned to the caller — equivalent to HikariCP's connectionInitSql. If the statement fails the connection is closed and the exception propagates.

Usage:

val hikariDS = HikariDataSource(config)
val stormify = Stormify(hikariDS) // Uses convenience function
// or
val stormify = Stormify(JdbcDataSource(hikariDS, initSql = "PRAGMA foreign_keys = ON"))

Constructors

Link copied to clipboard
constructor(jdbc: DataSource, initSql: String? = null)

Functions

Link copied to clipboard
open override fun getConnection(): Connection

Opens and returns a new database connection. The caller is responsible for closing it.