Getting error while running a code from itversity cca175 cource

scala

#1

Hi,
Heres my code
package main.scala

import java.sql.{Connection,DriverManager}

case class EmployeesCommision(first_name: String
,last_name: String,
salary: Double,
commission_pct: Double){
override def toString():String = {
“first_name: " +first_name + “;” +“last_name: " +last_name +”;”+“commission amount: " + getCommissionAmount() +”;"
}

def getCommissionAmount(): Any = {
if(commission_pct == null){
“not eligible”
}else salary * commission_pct
}
}

object CommisionAmount {
def main(args: Array[String]): Unit ={
val url = "jdbc:mysql://nn01.itversity.com:3306/hr"
val driver = "com.mysql.jdbc.Driver"
val username = "hr_ro"
val password = “itversity”

Class.forName(driver);
val connection = DriverManager.getConnection(url,username,password)

val statement = connection.createStatement()
val rs = statement.executeQuery(s"SELECT first_name, last_name,salary,commission_pct " +
  "from employees")
while (rs.next) {
  val e= EmployeesCommision(rs.getString("first_name"),
    rs.getString("last_name"),
    rs.getDouble("salary"),
    rs.getDouble("commission_pct"))
  println(e)
}

}
}

Error: Could not find or load main class main.scala.CommissionAmountTrial
Process finished with exit code 1

Please help me resolve the code error.


#2

I think you are trying to run some other file from the error. Can you check since CommissionAmountTrail is not specified in the above code.