This is the way you don’t need to change the source code

// case class User1(id: Long, name: String, password: String, imgUrl: String, update_date: String) object SparkSQLUpdateMySQLOfJDBC { def main(args: Array[String]): Unit = { //SparkSession val spark: SparkSession = SparkSession.builder().appName(" SparkSqlTomysql ").master("local").getOrCreate() // Read json/ CSV file data val df = spark.read.json("data/user.json") df.show() val data: Array [Row] = df. Collect () / / create a database connection val connection = DriverManager. GetConnection (" JDBC: mysql: / / localhost: 3306 / SSM? characterEcoding=UTF-8", "root", "000000") / / statement execution of SQL val statement = connection. The prepareStatement (" update user set name =? , password=? , imgUrl=? , update_date=? where id=?" ) // The assembly parameter val now: String = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now) data.foreach( u => { // Statement.setObject (1, U.getString (2)) Statement.setObject (2, 2) u.getString(3)) statement.setObject(3, u.getString(4)) statement.setObject(4, now) statement.setObject(5, U.GetLong (0) Statement.addBatch () // Execute Batch() Spark. Stop ()}

The garbled code ‘?? ‘of the situation, there is the big guy who knows to give directions