I am trying to write a standalone java class (with main function) to understand the working of JDBC. I have downloaded the MySQL installer for Windows from the mysql site and installed it. Now I am trying to run the following code to see if a successful connection is being made.
It compiles fine, but at runtime, throws an exception
java.lang.ClassNotFoundException : com.mysql.jdbc.Driver
Can anyone please point out what I need to do? My guess is, either my class name in incorrect, or I need to put the mysql jar in a particular folder. Which one is it? Also, this code above is not written by me. I got it from a tutorial site. Hence, is it possible that the values of
I have a variable named Path = C:\Program Files (x86)\Java\jdk1.6.0_21\bin
I have another variable named JAVA_HOME = C:\Program Files (x86)\Java\jdk1.6.0_21
I have kept the jar in both the above folders, and also inside folder C:\Program Files (x86)\Java\jdk1.6.0_21\lib.
My java file is in the same place where I have all my other java files. And then I use the commands
The error is still there.
Can you please tell me where exactly you want me to put it, apart from these places? I must mention that I do not have any environment variable called CLASSPATH, and this hasn't prevented me from running my other java files successfully.
author & internet detective