Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

Any better, more idiomatic way to convert SQL ResultSet to a Scala List or other collection type?

Why don't you try this:

new Iterator[String] {
  def hasNext = resultSet.next()
  def next() = resultSet.getString(1)
}.toStream

Taken from this answer here


I have a similar problem and my solution is:

Iterator.from(0).takeWhile(_ => rs.next()).map(_ => rs.getString(1)).toList

Hope that will help.

Tags:

Jdbc

Scala

Related

Unable to open the NuGet Package Manager Console Binding list of data.tables by columns, and by reference jQuery how to fix Cannot set property '_DT_CellIndex' of undefined? Listening for key events in angular Unresolved attribute reference 'keys' for class 'dict' How to install old version of Git on Windows 10 GraphQL gql Syntax Error: Expected Name, found } ObjectMapper can't deserialize without default constructor after upgrade to Spring Boot 2 Dynamically add meta description based on route in Angular Yml config files "Inheritance" with Spring boot protobuf vs gRPC Adding regularizer to an existing layer of a trained model without resetting weights?

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy