OracleDriver ClassNotFound
Answered
Hello community,
I am a new user of IntelliJ, i am trying to connect my app to my database and i am getting the following.
I've tried to add the ojdbc6 jar into my project anywhere (/lib, Project Structure -> Modules -> Dependencies, Project Structure -> Modules -> Libraries, src/lib)
and i can't connect to my database using the following:
Sql.newInstance(URL,USER,PASSWORD,"oracle.jdbc.OracleDataSource")
Logs:
- Class
- java.lang.ClassNotFoundException
- Message
- null
- Caused by
- oracle.jdbc.OracleDataSource
Line | Method ->> 211 | invoke in org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 188 | invoke in org.grails.core.DefaultGrailsControllerClass | 90 | handle . . . . . in org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter | 963 | doDispatch in org.springframework.web.servlet.DispatcherServlet | 897 | doService . . . in '' | 970 | processRequest in org.springframework.web.servlet.FrameworkServlet | 861 | doGet . . . . . in '' | 846 | service in '' | 55 | doFilterInternal in org.springframework.boot.web.filter.ApplicationContextHeaderFilter | 77 | doFilterInternal in org.grails.web.servlet.mvc.GrailsWebRequestFilter | 67 | doFilterInternal in org.grails.web.filters.HiddenHttpMethodFilter | 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor | 617 | run . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread Caused by ClassNotFoundException: oracle.jdbc.OracleDataSource ->> 381 | findClass in java.net.URLClassLoader - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 424 | loadClass in java.lang.ClassLoader | 357 | loadClass . . . in '' | 264 | forName in java.lang.Class | 716 | loadDriver . . . in groovy.sql.Sql | 447 | newInstance in '' | 20 | index . . . . . in HorarioController.groovy | 211 | invoke in org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker | 188 | invoke . . . . . in org.grails.core.DefaultGrailsControllerClass | 90 | handle in org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter | 963 | doDispatch . . . in org.springframework.web.servlet.DispatcherServlet | 897 | doService in '' | 970 | processRequest . in org.springframework.web.servlet.FrameworkServlet | 861 | doGet in '' | 846 | service . . . . in '' | 55 | doFilterInternal in org.springframework.boot.web.filter.ApplicationContextHeaderFilter | 77 | doFilterInternal in org.grails.web.servlet.mvc.GrailsWebRequestFilter | 67 | doFilterInternal in org.grails.web.filters.HiddenHttpMethodFilter | 1142 | runWorker . . . in java.util.concurrent.ThreadPoolExecutor | 617 | run in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run . . . . . . in java.lang.Thread
Please sign in to leave a comment.
Could you please check ojdbc6.jar really has oracle.jdbc.OracleDataSource class?
Please share the code that explicitly uses this class.
Probably you need to use oracle.jdbc.pool.OracleDataSource instead.
Tried using :
- oracle.jdbc.OracleDataSource
- oracle.jdbc.pool.OracleDataSource
- oracle.jdbc.driver.OracleDataSource
- oracle.jdbc.OracleDriver
- oracle.jdbc.pool.OracleDriver
- oracle.jdbc.driver.OracleDriver
But no luck on them.
This is the code im using:
Can you show the classpath of the module and how ojdbc6.jar is added to the module dependencies? https://www.jetbrains.com/help/idea/2017.1/working-with-module-dependencies.html.
"oracle.jdbc.OracleDriver" should work.
This is how i have it.
Since your project is Gradle based, why don't you add this dependency via Gradle instead? Note that IntelliJ IDEA will revert all the dependencies you've added manually on the next Gradle refresh. Make sure your build.gradle has something like this: http://stackoverflow.com/a/33248711/104891.
Also, do you use any artifacts? If so, make sure this jar is also added to the artifact: https://www.jetbrains.com/help/idea/artifacts.html.
Added this line to my dependencies in build.grlade and it worked!!!
runtime files('lib/ojdbc6.jar')Thank you.