// 方法一、
val option = Map("..." -> "...",...)
df.write.mode(SaveMode.Overwrite).format("jdbc").options(option).save()
/**
1、如果将SaveMode.Overwrite改为SaveMode.Append可能报如下错误
ERROR ApplicationMaster: User class threw exception: java.lang.RuntimeException: org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider does not allow create table as select.
**/
// 方法二、
val prop: java.util.Properties = ......
df.write.jdbc("jdbc:mysql://localhost/foo", "foo.bar2", prop)
// df.write.mode(SaveMode.Overwrite).jdbc("jdbc:mysql://localhost/foo", "foo.bar2", prop)