jonathan-dufaul
Valued Contributor

Chiming in because I don't know if the above quite answers how to execute a stored procedure. I use PySpark. I believe this should work for oracle, but only was able to test it with MS Sql Server. I had to truncate a table, but the code works for a stored procedure as well.

https://stackoverflow.com/questions/74439747/is-there-a-way-to-just-truncate-a-remote-mssql-table-fr...

General idea is to get the jdbc connection from the jvm gateway and use that to execute sql commands.

sqlSurl = "jdbc:[driver]//ip..."
 
  con = (sc._gateway
          .jvm
          .java
          .sql
          .DriverManager
          .getConnection(sqlsUrl, \
            username, \
            password)
    )
  con.prepareCall(query).execute()
  con.close()