I am trying to use the MySQL driver for java and I keep getting a ClassNotFoundException. I am not using an IDE at all, the program is being written in Vim and compiled at the Window's command line. It's for a class and the professor has told us we cannot use an IDE at all. I added the JAR file to the Window's PATH System Environment Variable but I'm still getting the error. I must be doing something wrong but most of the research I've done just pulls up that you need to add the driver to your IDE's classpath but I'm not using an IDE, just Windows.
Here's my code:
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e) {
System.out.println("Where is your MySQL JDBC Driver?");
e.printStackTrace();
return;
}
And the error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sqlAccess.<init>(sqlAccess.java:21)
at Tester.DoOther(Tester.java:44)
etc
And this is what I added to my PATH
variable under System Variables:
C:\Program Files\Java\jdk1.7.0_11\bin\mysql-connector-java-5.1.24-bin.jar
What am I missing?