Treating an SQL ResultSet like a Scala Stream

前端 未结 10 2244
天涯浪人
天涯浪人 2020-12-02 10:11

When I query a database and receive a (forward-only, read-only) ResultSet back, the ResultSet acts like a list of database rows.

I am trying to find some way to trea

10条回答
  •  情歌与酒
    2020-12-02 10:40

    I didn't test it, but why wouldn't it work?

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

提交回复
热议问题