문제

I'm trying to connect Oracle database using this tutorial. It is working when I use command line: java -cp c:\jdbc-test\ojdbc6.jar;c:\jdbc-test OracleJDBC I have put ojdbc6.jar in the same folder with OracleJDBC.java. Now I need to run it on Eclipse, but it gives me an error:

Output: *Where is your Oracle JDBC Driver?

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:190) at OracleJDBC.main(OracleJDBC.java:32)*

Is it because of ojdbc6.jar location?

도움이 되었습니까?

해결책

Add the library in the project build path.

  • Right click on project
  • Build Path
  • Go to Libraries Tab
  • Add external jar (ODBC jar) there

Right Click on project for Build Path option

Java Build Path libraries configuration

다른 팁

You just need to add ojdbc6.jar into classpath of your application.

you need to keep the jar file in external library follow this way

  1. right click on your project
  2. click "build path"
  3. click "configure build path"
  4. click "library " tab
  5. click "add external jars"
  6. give the path of the jar file

Then run it Please see the screenshots enter image description here enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top