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

com.vladsch.kotlin.jdbc.Session.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.CallableStatement
import java.sql.PreparedStatement
import java.sql.ResultSet
import javax.json.JsonArray
import javax.json.JsonObject

interface Session : AutoCloseable {
    val connection: Connection
    val autoGeneratedKeys: List
    val identifierQuoteString:String

    fun use(block: (Session) -> Unit)

    fun prepare(query: SqlQuery, returnGeneratedKeys: Boolean = false): PreparedStatement
    fun prepare(query: SqlCall): CallableStatement
    fun prepare(query: SqlQueryBase<*>): PreparedStatement

    fun  query(query: SqlQueryBase<*>, consumer: (ResultSet) -> A): A

    fun  execute(query: SqlQueryBase<*>, consumer: (PreparedStatement) -> A): A?
    fun  execute(query: SqlCall, consumer: (CallableStatement) -> A): A?

    fun  executeWithKeys(query: SqlQuery, consumer: (PreparedStatement) -> A): A?
    fun  updateWithKeys(query: SqlQuery, consumer: (PreparedStatement) -> A): A?
    fun  update(query: SqlQueryBase<*>, consumer: (PreparedStatement) -> A): A?
    fun  list(query: SqlQueryBase<*>, extractor: (Row) -> A): List
    fun jsonArray(query: SqlQueryBase<*>, extractor: (Row) -> JsonObject): JsonArray
    fun count(query: SqlQueryBase<*>): Int
    fun  first(query: SqlQueryBase<*>, extractor: (Row) -> A): A?
    fun  hashMap(query: SqlQueryBase<*>, keyExtractor: (Row) -> K, extractor: (Row) -> A): Map
    fun jsonObject(query: SqlQueryBase<*>, keyExtractor: (Row) -> String, extractor: (Row) -> JsonObject): JsonObject
    fun forEach(query: SqlQueryBase<*>, operator: (Row) -> Unit)

    @Deprecated(message = "Use executeCall(query: SqlCall, stmtProc: (results: SqlCallResults) -> Unit) instead", replaceWith = ReplaceWith("executeCall"))
    fun forEach(query: SqlCall, stmtProc: (stmt: CallableStatement) -> Unit, operator: (rs: ResultSet, index: Int) -> Unit)
    fun executeCall(query: SqlCall, stmtProc: (results: SqlCallResults) -> Unit)

    fun execute(query: SqlQueryBase<*>): Boolean
    fun update(query: SqlQueryBase<*>): Int
    fun updateGetLongId(query: SqlQuery): Long?
    fun updateGetId(query: SqlQuery): Int?
    fun  updateGetKey(query: SqlQuery, extractor: (Row) -> A): A?
    fun updateGetLongIds(query: SqlQuery): List?
    fun updateGetIds(query: SqlQuery): List?
    fun  updateGetKeys(query: SqlQuery, extractor: (Row) -> A): List?
    fun  transaction(operation: (Transaction) -> A): A

    override fun close()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy