3

Hi I am facing the below issue while executing Sparksql Job(to read the Oracle table) in IntellJ IDE. Issue: Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

I have already added the ojdbc7.jar file in my project in IntelliJIdea ProjectStructure==>Modules==> Dependencies ==> + ==> Added ojdbc7.jar file.

In build.gradle file i have given the below statement.

"runtime files('libs/ojdbc7.jar')"

After i compiled my project i could see the jar file in libs folder that i have created in my project.

If i execute the Job in IDE I am facing this issue. Can any one please help me on the same.

10
  • how are you executing the Sparksql Job ? Commented Oct 2, 2016 at 16:16
  • @Arunakiran, from IDE Commented Oct 2, 2016 at 16:19
  • Please post your code Commented Oct 2, 2016 at 16:20
  • ` val query = "(SELECT * FROM tablename limit 3) QUERYNAME" val temp_df = sqlContext.read .format("jdbc") .option("driver", "oracle.jdbc.driver.OracleDriver") .option("url", "url") .option("dbtable", query).load() temp_df.show(5)` Commented Oct 2, 2016 at 16:25
  • This is the code that I am trying to submit. Commented Oct 2, 2016 at 16:27

1 Answer 1

6

You need to download the driver on Intellij IDE itself and not the project you are working on since it's Intellij that needs the driver, the one in your project you can keep it since your application will need it. In your IDE, go to Database Menu on your right, chose the connection you created to connect to the DB then Properties. At the bottom it should show you a link, Download Missing Driver, click on that and you should be able to do your SQL queries using Intellij IDE.

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.