Q:

sql connection in java

why I cant to MySQL and have error in this code
public class test1 {

    public static void main(String[] args) {
        try {
        //  Class.forName("com.mysql.jdbc.Driver");
            Class.forName("com.mysql.jdbc.Driver");

        } catch (ClassNotFoundException e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
        }
    }

}

I am downloading connection java and set classpath in my setting but my problem not destroyed
please help to me
my error is
com.mysql.jdbc.Driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    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 test1.main(test1.java:7)

A:

Error clearly says you don't have added the driver to your project!!! You have to add the *.jar  driver to your project.
Put this in your lib directory, then restart
Why is this happening?

Class.forName("com.mysql.jdbc.Driver"); it tries to load the driver, but it is not getting it, this is the reason you are getting java.lang.ClassNotFoundException

You can find the jar file here

