2

The ojdbc7.jar file is located in referenced libraries and lib. However, java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver is specified. What to do?

Also, wrote Class.forName("oracle.jdbc.driver.OracleDriver");.

karthik akinapelli
  • 710
  • 1
  • 7
  • 14
Test
  • 131
  • 1
  • 9
  • Try `Class.forName("oracle.jdbc.OracleDriver");` – g00se Aug 11 '21 at 10:07
  • @g00se was the same :( – Test Aug 11 '21 at 10:08
  • Possibly worth looking in to the jar to see if that class is present – g00se Aug 11 '21 at 10:11
  • Looks like your jar isn't in the classpath. – jpllosa Aug 11 '21 at 10:18
  • @jpllosa is this window/preferences/build path/classpath variables? – Test Aug 11 '21 at 10:26
  • @jpllosa it contains jre_lib, jre_src, jre_srcroot and junit_home – Test Aug 11 '21 at 10:27
  • Don't know about your setup but the classpath a way to tell applications, including the JDK tools, where to look for user classes. In the command line it goes something like this `java -classpath C:\myclasses`. In an IDE, should be somewhere in Build/Run > Configuration or something like that. – jpllosa Aug 11 '21 at 10:34
  • aa it's eclipse @jpllosa – Test Aug 11 '21 at 10:36
  • @g00se - Just to be clear: since Java 5, you don't *need* to use `Class.forName` to load a JDBC driver. (And in some circumstances, it a bad thing to do.) Instead you should use `DriverManager` and let it discover the drivers from the runtime classpath. (Assuming that the driver JAR is on the runtime classpath ... which is what the OP's real problem was.) – Stephen C Aug 12 '21 at 04:45
  • @Stephen C I'm aware of that, My comment was made for diagnostic purposes only – g00se Aug 12 '21 at 09:10

1 Answers1

0

It's me. It's just that when I export the jar file, click runnable jar and select package required libraries into generated JAR. Thank you guys.

Test
  • 131
  • 1
  • 9