com.vladsch.kotlin.jdbc.Connection.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-jdbc Show documentation
Show all versions of kotlin-jdbc Show documentation
A thin library that exposes JDBC API with the convenience of Kotlin and gets out of the way when not needed.
The newest version!
package com.vladsch.kotlin.jdbc
import java.sql.SQLException
data class Connection(
val underlying: java.sql.Connection,
val driverName: String = "",
val jtaCompatible: Boolean = false
) : java.sql.Connection by underlying {
fun begin() {
underlying.autoCommit = false
if (!jtaCompatible) {
underlying.isReadOnly = false
}
}
override fun commit() {
underlying.commit()
underlying.autoCommit = true
}
override fun rollback() {
underlying.rollback()
try {
underlying.autoCommit = true
} catch (e: SQLException) {
}
}
override fun close() {
underlying.close()
}
}