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.