MySqlRead.scala - Compilation error



0

I have configured the Scala IDE on Ubuntu VM. While compiling the MySqlRead (refer to the SQL program list in Session 7 Notes, shared by Prahanth) program, the following compilation error is displayed:

 
 
At this line: 'val option = Map("url" => "jdbc:mysql://localhost:3306/ecommerce", "dbtable" => "sales","user"=>"root","password"=>"abc123")"
 
Error: " not a legal formal parameter. Note: Tuples cannot be directly destructured in method or function parameters. Either create a single parameter accepting the Tuple1, or consider a pattern matching anonymous function: `{ case (param1, param1) => ... }
 
I would greatly appreciate if you would provide a resolution to this issue, at the earliest.
 
Regards, Sri
 

 


1 Answer(s)


0

I believe you are working with Spark 2x then try this:

            val properties = new Properties()
            properties.setProperty("user","<username>")
            properties.setProperty("password","<password>")

           df.write.jdbc("jdbc:mysql://localhost:3306/ecommerce","sales",properties)

 

Regards,

Sakhuja

Your Answer

Click on this code-snippet-icon icon to add code snippet.

Upload Files (Maximum image file size - 1.5 MB, other file size - 10 MB, total size - not more than 50 MB)

Email
Password