sql = " select * from表"用戶= "密碼= "服務器= "端口= service_name =“jdbcUrl = f”jdbc: oracle:薄:@{服務器}:{港口}:{service_name} oracle.jdbc.driver jdbcDriver =。甲骨文Driver" DF = spark.read.format("jdbc") \ .option("url", jdbcUrl) \ .option("query", sql) \ .option("user", user) \ .option("password", password) \ .option("driver", jdbcDriver) \ .load() by this you can make a connection with your oracle database and read files from the database and same you can write the data to particular database .
Df.write.format (jdbc)。選項(url = " jdbc: oracle:薄:@192.168.11.100:1521:李艾科,司機= ' oracle.jdbc.driver。OracleDriver testschema,數據表=。測試,用戶= ' testschema”,密碼= '密碼').mode(覆蓋).save ()
試試這個。參考鏈接:https://dwgeek.com/load-spark-dataframe-to-oracle-table-example.html/