close

open override fun close()(source)

Releases the resources this database holds so its backing files can be deleted or replaced. Idempotent. After close the database is unusable: metadata and query operations route through longLastingConnection, which is now closed.

  • Closes the single long-lived JDBC connection (longLastingConnection) if it was ever opened. A held connection is what locks the SQLite .db file on Windows; closing it releases the file.

  • For an embedded Derby database, additionally issues the engine shutdown, because Derby keeps the database booted — holding db.lck — after every connection is closed, until an explicit ;shutdown=true.

  • If dataSource is a pool (a HikariCP HikariDataSource, used by the properties/Postgres path), closes it too. The plain embedded SQLite/Derby data sources are not AutoCloseable, so this is a no-op for them.