I am trying to connect to oracle db through java code on windows. But getting this error "java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver" I placed 'ojdbc8'in the path (advanced settings-->env variables). but still i am getting same error. One more point is Oracle is not installed in my local , it is some other machine (server). I have installed SQL developer , so in the sqldeveloper folder (C:\Program Files\sqldeveloper-18.3.0.277.2354-x64\jdbc\lib) there is ojdbc8 jar file is present. so i copied it from there and placed in C:\Program Files/java/jre/lib/ext . Am i doing any wrong here?
-
How is your work environment? Are you using an IDE, like Eclipse? How are you executing your Java code, by the IDE?dliber– dliber2019-08-30 15:30:04 +00:00Commented Aug 30, 2019 at 15:30
-
No . I am not using any IDE. I am trying run through commond prompt (CMD)n_ravikumar1– n_ravikumar12019-08-30 15:42:34 +00:00Commented Aug 30, 2019 at 15:42
-
Is your issue fixed?Sujay Mohan– Sujay Mohan2019-09-15 16:13:15 +00:00Commented Sep 15, 2019 at 16:13
Add a comment
|
1 Answer
Adding ojdbc8 in environment variable "path" will not add it to Class path. If you want to run the class with driver jar, While running the class please use the command java -classpath "path to ojdbc8 jar" "your class file name with package". Or you need to set the path of the jar in environment variable "classpath" and run your java class. If you already add your jar in classpath. Please recheck the path of the jar file.