Q: Even after adding mysql Jconnector to CLASSPATH, getting java.lang.ClassNotFoundException(Not using IDE) I'm trying to connect with mysql from java and these are my CLASSPATH variable values which I've set using GUI in windows(control panel->system->advanced system settings->environment variables).

.;.;.;.;.;C:\PROGRA~2\JMF21~1.1E\lib\sound.jar;C:\PROGRA~2\JMF21~1.1E\lib\jmf.jar;C:\PROGRA~2\JMF21~1.1E\lib;E:\Face_rec\FaceDetect-java\lib\facedetect-openimaj.jar;C:\Program
  Files (x86)\MySQL\Connector J 5.1.27\mysql-connector-java-5.1.27-bin.jar

The bolded one is the classpath that I'm dealing with. Even though all different paths are separated by semicolon and the mysql-connector-java-5.1.27-bin.jar has been added to CLASSPATH i'm getting this error when I run my code.

java.lang.ClassNotFoundException: com.sql.jdbc.Driver.

this is the part of the code. And I've imported,
import java.awt.*;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.JTextField;
import javax.swing.ImageIcon;

ok.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent ae)
            {
                String test=jf1.getText();
                String testa=jf2.getText();
                String n;
                String m;
                try
                {
                    Class.forName("com.mysql.jdbc.Driver");
                    Connection con=DriverManager.getConnection

("jdbc:mysql://localhost/authentication?"+"user=root&password=letmein");
                    PreparedStatement p=con.prepareStatement("Select * from authentication.admin where 

id Like '"+test+"%'");
                    ResultSet rs=p.executeQuery();
                        rs.next();
                        n=rs.getString("Username");
                        m=rs.getString("Password");
                        con.close();
                    if(n.equalsIgnoreCase(test) && m.equalsIgnoreCase(testa))
                    {
                            JOptionPane.showMessageDialog(null,"Your username and password is 

correct");
                    }
                    else
                    {
                            JOptionPane.showMessageDialog(null,"Your username or password is 

incorrect");
                    }

                }
                catch(Exception es)
                {
                    System.out.println(es);
                }

            }
        });

Update:I'm not using any IDE(Eclipse of netbeans). I'm using only command prompt. 
Please help me to solve this.

A: You should also put it into your project.
Depends on build tool you are using, but if you just copy it into lib folder will work in most cases.

A: You must add the jar in the Lib folder of your project too.
Steps:


*

*Open Command Prompt. 

*Go to the path where you have created the project.
For Ex: If you have created your project in C:\Workspace\Test(where Test is your project name) 

*In Command Prompt, type C:> cd C:\Workspace\Test

*Now your command prompt would look like this C:\Workspace\Test>

*Type dir after Test, it would show you the directory structure of
your Project. Check if you have any Lib folder in that structure.

*If you have a lib folder, type dir lib in the command prompt which
would show you the list of jars available in your project.

*You can add mysql-connector-java-5.1.27-bin.jar in lib if you don't find it.


Let me know if this helped.
