2015-01-21 2 views
2

Я пытаюсь вставить несколько данных в apple_reportDB, но я получаю сообщение об ошибке, как Too many arguments for method in the insert queryпоказывает слишком много аргументов для метода

import scala.slick.driver.MysqlDriver.simple._ 

case class AppleReport(quantity:String,price:String,sale_amount:String) 

//tables 
class Suppliers(tag: Tag) 
    extends Table[AppleReport](tag, "apple_report") { 

def quantity=column[String]("quantity") 
def price=column[String]("price") 
def sale_amount=column[String]("sale_amount") 

def * =(quantity,price,sale_amount) <> (AffiliateReportFields.tupled,AffiliateReportFields.unapply) 
} 

    //declaring interface 
val suppliers: TableQuery[Suppliers] = TableQuery[Suppliers] 

val db=Database.forURL("jdbc:mysql://localhost:3306/apple_reportDB","root","",null, driver="com.mysql.jdbc.Driver") 
    db.withSession { implicit session => 

//create table 
suppliers.ddl.create 
//Insert data 
suppliers += ("apple","cow","cat") 

    } 

ответ

4

Вашего Suppliers стол расширяет Table[AppleReport]. Следовательно, ваш оператор insert ожидает один объект класса case AppleReport.

Однако вы вызываете метод с 3 строками ("apple","cow","cat") и, следовательно, с ошибкой. Измените его на AppleReport("apple","cow","cat") и ваш код будет работать