Skip to content

Commit

Permalink
Using resource
Browse files Browse the repository at this point in the history
  • Loading branch information
IceMimosa committed Jul 24, 2023
1 parent fea88b7 commit 8d685d4
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ object ResultSetXMacro {
override def fetch(typeMappingFunc: TypeMappingArgs => TypeRow): LazyList[TypeRow] =
val columnSize = resultSet.getMetaData.getColumnCount
val result = _root_.scala.collection.immutable.LazyList.newBuilder[TypeRow]
while (resultSet.next()) {
val row = typeMappingFunc(TypeMappingArgs(resultSet, columnSize))
result.addOne(row)
scala.util.Using.resources(stat, resultSet) { (_, rs) =>
while (rs.next()) {
val row = typeMappingFunc(TypeMappingArgs(rs, columnSize))
result.addOne(row)
}
}
if (!resultSet.isClosed()) resultSet.close()
if (!stat.isClosed()) stat.close()
result.result()
}
}

0 comments on commit 8d685d4

Please sign in to comment.