0

I have Spark 3.1.2 and Scala 2.12.8. I want to connect to oracle Database and read a table then show it, using this code:

import org.apache.spark.sql.SparkSession

object readTable extends App{

   val spark = SparkSession
           .builder
           .master("local[*]")
           .appName("Spark SQL basic example")
           .config("spark.some.config.option", "some-value")
           .getOrCreate()

   val jdbcDF = spark.read
           .format("jdbc") 
           .option("url", "jdbc:oracle:thin:@x.x.x.x:1521:orcldb")
           .option("dbtable", "orcl.brnc_grp")
           .option("user", "orcl")
           .option("password", "xxxxxxx")
           .load()

jdbcDF.show()

}
  

When I run the code, I receive this error:

Exception in thread "main" java.sql.SQLException: No suitable driver

Would you please guide me how to solve this problem?

Any help would be really appreciated.

1 Answer 1

1

Download oracle JDBC jar from here and place this JAR in $SPARK_HOME/jars folder.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.