spark2.0 连接mysql8.0数据库操作表数据
时间:2021-07-01 10:21:17
帮助过:27人阅读
operationMysql
import config.conf.{sc, spark_session}
import org.apache.spark.sql.DataFrame
object readingMysqlOperation {
def main(args: Array[String]): Unit =
{
val df: DataFrame =
spark_session.read
.format("jdbc"
)
.option("url", "jdbc:mysql://localhost:3306/junsheng?useUnicode=true&characterEncoding=utf-8"
)
.option("dbtable", "订单"
)
.option("user", "root"
)
.option("password", "123456"
)
.load()
df.show()
}
}
spark2.0 连接mysql8.0数据库操作表数据
标签:enc div nic mysql localhost reading pack apache load