Spark SQL操作数据源
Exception in thread “main” java.sql.SQLException: Access denied for user ‘root’@‘192.168.52.1’ (using password: YES)
虚拟机拒绝访问,把pom.xml依赖的版本改为8.0.13 mysql
mysql-connector-java
8.0.13
Exception in thread “main” java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrec
该错误为是系统时间错误
只需要在访问数据库的Url后面加上以下的语句即可:
?serverTimezone=GMT%2B8
原来:val mysqlDF: DataFrame = spark.read.jdbc(“jdbc:mysql://localhost:3306/spark”,“person”,properties)
改后:val mysqlDF: DataFrame = spark.read.jdbc(“jdbc:mysql://localhost:3306/spark?serverTimezone=GMT%2B8”,“person”,properties)
解决这两个问题,今天搞了一整天,一个版本问题一个5.多的驱动用不了,要在后面加上?serverTimezone=GMT%2B8 终于搞定了
import java.util