在系统变量下添加了ojdbc6.jar文件路径,但获取classNotFoundException:oracle.jdbc.driver.oracledriver for Java 18,Oracle 11G
我使用以下Java代码连接到Oracle数据库,
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","root");
我的Oracle版本是11.2g。我将ojdbc6.jar和ojdbc6_g.jar添加到路径c:\ program文件\ java \ jdk-18.0.1.1.1 \ lib。
我已经在路径下的系统变量中添加了Java bin和lib文件夹路径 ,
但是当我尝试运行程序时,我会收到以下错误: classNotFoundException:oracle.jdbc.driver.oracledriver。
任何人都可以帮助我解决问题。我尝试了Stackoverflow和其他资源的所有可能方法,但无法解决问题。
I have used below java code to connect to oracle database
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","root");
My java version is "18.0.1.1".
My oracle version is 11.2g. I added the ojdbc6.jar and ojdbc6_g.jar to the path C:\Program Files\Java\jdk-18.0.1.1\lib.
I have added java bin and lib folder path to system variables under path
But still when I try to run the program, I am getting the below error:
ClassNotFoundException: oracle.jdbc.driver.OracleDriver.
Can anyone please help me to solve the problem. I tried all possible ways from stackoverflow and other resources but couldn't solve the issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,我得到了这个错误的解决方案。因此,首先确保您在路径变量下添加了Oracle bin路径和JDK bin路径。然后在系统变量下创建新的变量类路径,然后将Oracle Jar路径和JDK bin路径添加到该变量。
Finally, I got the solution for this error. So, first make sure that you have added oracle bin path and jdk bin path under path variable. Then under system variables create new variable CLASSPATH and add oracle jar path and jdk bin path to that variable.