diff --git a/src/jvmMain/kotlin/ru/langrafhomyak/db/jdbc_resources_manager/entry_points.kt b/src/jvmMain/kotlin/ru/langrafhomyak/db/jdbc_resources_manager/entry_points.kt new file mode 100644 index 0000000..d965589 --- /dev/null +++ b/src/jvmMain/kotlin/ru/langrafhomyak/db/jdbc_resources_manager/entry_points.kt @@ -0,0 +1,21 @@ +@file:JvmName("_EntryPointsKt") + +package ru.langrafhomyak.db.jdbc_resources_manager + +import java.sql.Connection +import java.sql.PreparedStatement +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract +import ru.landgrafhomyak.utility.highlevel_try_finally.safeAutoClose1 + +@JvmName("prepareStatement") +public fun Connection.prepareStatement(ps: PreparedStatementsCompilationCache): PreparedStatement = ps.preparedStatementForConnection(this) + +@JvmName("prepareStatement\$autoclose") +public fun Connection.prepareStatement(ps: PreparedStatementsCompilationCache, preparedStatementScope: (ps: PreparedStatement) -> R): R { + contract { + callsInPlace(preparedStatementScope, InvocationKind.EXACTLY_ONCE) + } + val w = ps.preparedStatementForConnection(this) + return safeAutoClose1(finally = w::close) { preparedStatementScope(w) } +} \ No newline at end of file