/usr/app/spark-2.4.7-bin-hadoop2.7/bin/spark-submit--jars$HUDI_SPARK_BUNDLE--masterspark://10.20.3.72:7077--driver-class-path$HADOOP_CONF_DIR:/usr/app/apache-hive-2.3.8-bin/conf/:/software/mysql-connector-java-5.1.49/mysql-connector-java-5.1.49-bin.jar--confspark.serializer=org.apache...
在使用Spark将数据写入MySQL之前,我们需要在Spark代码中指定正确的编码格式。我们可以使用option方法设置charset选项来指定编码格式。 valjdbcUrl="jdbc:mysql://localhost:3306/database_name"valtableName="table_name"valconnectionProperties=newjava.util.Properties()connectionProperties.setProperty("user","your_usernam...
.getOrCreate() // 设置MySQL连接信息 val mysqlUrl = "jdbc:mysql://<mysql_host>:<mysql_port>/<mysql_database>" val mysqlUser = "<mysql_username>" val mysqlPassword = "<mysql_password>" val mysqlTable = "<mysql_table>" // 读取MySQL数据 val mysqlDF = spark.read.format("jdbc") ....