import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
//This class is for testing connection with mysql database
class JDBCTest {
// path to database is stored in string url
private static final String url = "jdbc:mysql://localhost";
// username is stored in string root
private static final String user = "root"; //username
// password is stored in string password
private static final String password = "swapnil";//password
public static void main(String args[]) {
try {
//i have stored driver in c:\javap\
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection(url, user, password);
System.out.println("Success");
} catch (Exception e) {
System.out.println("hi");
e.printStackTrace();
}
}
}
whenever I try to run this program I get the exception
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
I am using mysql database my operating system is windows 7 64 bit. I have included the mysql-connector-java-5.1.22-bin in jdk/jre/lib/ext I have also set up the CLASSPATH Environment variable but nothing work me out