query

@ExperimentalCoroutinesApi
fun Jdbc.query(sql: String, fetchSize: Int = 100, prepare: suspend PreparedStatement.() -> Unit = {}): Flow<Row>

Executes a query for the given SQL statement using the provided fetchSize as a result set fetch size.

Return

a Flow of Row objects, representing the result set.

Example usage:

val result = Jdbc.query("SELECT * FROM my_table WHERE id = ?") {
setInt(1, 10)
}
result.collect { println(it) }

Parameters

sql

the SQL statement to be executed

fetchSize

the result set fetch size to be used in the query (default: 100)

prepare

a function that prepares the PreparedStatement for the query (default: {})