cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to Call Oracle Stored Procedures from Databricks?

Raghu101
New Contributor III

How to Call Oracle Stored Procedures from Databricks?

6 REPLIES 6

Meghala
Valued Contributor II

here i have code

  1. val url =
  2. "jdbc:mysql://yourIP:yourPort/test?
  3. user=yourUsername; password=yourPassword"
  4. val df = sqlContext
  5. .read
  6. .format("jdbc")
  7. .option("url", url)
  8. .option("dbtable", "people")
  9. .load()

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()

AdrianLobacz
Contributor

Meghala
Valued Contributor II

Thanks it helps me as wellโ€‹

sher
Valued Contributor II

Meghala
Valued Contributor II

It was needed me as well so thanks โ€‹

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group