io.lenses.jdbc4.resultset.ResultSetIterator.kt Maven / Gradle / Ivy
package io.lenses.jdbc4.resultset
import java.sql.ResultSet
fun resultSetIterator(rs: ResultSet): Iterator {
return object : Iterator {
override fun next(): ResultSet = rs
override fun hasNext(): Boolean = rs.next()
}
}
fun resultSetList(rs: ResultSet): List> {
val results = mutableListOf>()
while (rs.next()) {
val row = (1..rs.metaData.columnCount).map { rs.getObject(it) }
results.add(row.toList())
}
return results.toList()
}
fun ResultSet.toList() = resultSetList(this)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy