All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vladsch.kotlin.jdbc.Connection.kt Maven / Gradle / Ivy

Go to download

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()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy