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

io.lenses.jdbc4.resultset.ResultSetIterator.kt Maven / Gradle / Ivy

There is a newer version: 3.0.2
Show newest version
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