Guys I am trying to get some results from mysql database and I am having error with fetching it onto scala.html file. Here are my codes:
/*Customers.scala. Its controller*/
package controllers
import play.api._
import play.api.mvc._
import models.Customers
object Customers extends Controller{
def customer = Action{
val nb_customers = Customers.allCustomers
Ok(views.html.customer(nb_customers)) //I am having error here.
}
// End of customer Action.
}
// End of Customer controller.
/*Now Customers.scala model*/
package models
import anorm._
import play.api.db._
import play.api.Play.current
case class Customers(CustomersID: Int, Name: String)
object Customers {
def allCustomers = {
DB.withConnection {implicit connection =>
SQL("Select * from Customers")().map{row =>
Customers(
CustomersID = row[Int]("CustomersID"),
Name = row[String]("Name")
)
// End of Customers object.
}.toList
// SQL ends.
}
// With connection.
}
// End of allCustomers.
}
// End of of Customers.
Please note, I am using JDBC driver for mysql connection in conf/application.conf file
Please help me out here. Thanks a lot.