I’ve installed MySQL Connector J, WAMP [which comes with MySQL], and Java JDK 1.7 but it always through exception com.mysql.jdbc.Driver
The code
import java.sql.*;
public class sou
{
public static void main (String[] args)
{
Connection conn = null;
try
{
String userName = "root";
String password = "";
String url = "jdbc:mysql://localhost/cms";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
conn.close();
}
catch (Exception e)
{
System.err.println (e.getMessage());
}
}
}
I’m compiling this as
C:\Users\Sou\Desktop>javac -cp "D:\Program Files\MySQL\Connector J 5.1.20.0\mysql-connector-java-5.1.20-bin.jar" sou.java
You have to include
mysql-connector-java-5.1.20-bin.jarin your CLASSPATH while compiling and running an application.And no need to call the newInstance() method.