← Back to Stormify Documentation

JdbcDataSource

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

JDBC DataSource wrapper that implements KDBC DataSource interface.

initSql runs on every freshly opened connection before it is returned to the caller — like HikariCP's connectionInitSql. Separate more than one statement with ;; each is run in order.

Usage:

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

Constructors

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

Functions

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

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