0
votes

I am trying to write a spark data frame to MYSQL table. I tried the following method:

dataFrame.write().mode(SaveMode.Append).format(JDBC).options(options);

options is a map of the following key-value pair:

  • "url", "jdbc:oracle:thin:@localhost:1521:xe"
  • "password", "pass"
  • "driver", "oracle.jdbc.driver.OracleDriver"
  • "user","username"
  • "dbtable","tableName"

table 'tableName' is not getting updated and I am not getting any error in spark console. Can someone help me with this?

1

1 Answers

0
votes

Try it by changing your map name because both method name and map name are the same. I am not sure but this might be the problem.

Secondly, I declare option parameters as separate variables and pass them into the option method.

`

url_name = "xxxx"
driver_name = "xxxx"
username = "x"
passwd = "123"
dataFrame.write().mode(SaveMode.Append).format(JDBC).options(url=url_name, driver = driver_name, dbtable = query, user=username, password=passwd);

`

The last thing, check the .save() method after options method because you are not saving.