需要从结果集创建Seq [String,String]

时间:2016-01-22 09:48:03

标签: scala

我试图从函数返回集合对象Seq [String,String]但它没有用。这是我的方法,请帮我解决这个问题

def findAllBrandsseq:Seq[String,String] ={
              val brands =Seq[String,String]()


                 val conn = DB.getConnection()
                 try {
                    val stmt = conn.createStatement
                    val rs = stmt.executeQuery("SELECT * from m_brand")
                    while (rs.next()) {

                      brands:+(rs.getString("idbrand"),rs.getString("brandName"))
                    }
                } finally {
                    conn.close()
                }
                return brands
 }

它提供以下编译错误

  

从stdout读取:   D:\ PROJECTS \ test \ Project_VendorM6 \ app \ models \ Brand.scala:49:错误   Seq的类型参数数量应为1   D:\ PROJECTS \ test \ Project_VendorM6 \ app \ models \ Brand.scala:49:错误   Seq的类型参数的数量应该是1从stdout:def读取   findAllBrandsseq:Seq [String,String] = {                def findAllBrandsseq:Seq [String,String] = {从stdout读取:^                                     ^从标准输出读取:

     

D:\ PROJECTS \ test \ Project_VendorM6 \ app \ models \ Brand.scala:50:错误

     
    

方法适用的类型参数数量:[A](元素:A *)Seq [A] in     class GenericCompanion     D:\ PROJECTS \ test \ Project_VendorM6 \ app \ models \ Brand.scala:50:错误     方法的类型参数数量适用:[A](元素:A *)Seq [A] in     class GenericCompanion从stdout:val品牌中读取     = SeqString,字符串                   val brands = SeqString,String从stdout读取:^

  

0 个答案:

没有答案