驱动程序不Foundjava.lang.ClassNotFoundException连接:com.mysql.jdbc.driver我想我的Java Web应用程序与mysql数据库,但得到的错误
我想打通过我的Java Web应用程序和MySQL数据库之间的连接XAMP。 我也添加了外部jar文件,它是mysql-connector-java-6.0.2.jar,但仍然出现此错误。
我已经完成了这段代码。
public static void main(String[] args)
{
try {
Class.forName("com.mysql.jdbc.driver");
System.out.println("Driver has been found..");
} catch (ClassNotFoundException ex) {
System.out.println("Driver Not Found"+ex);
}
String url="jdbc:mysql://localhost/hms";
String user="root";
String password="";
Connection con=null;
try {
con=DriverManager.getConnection(url, user, password);
System.out.println("Driver is successfully loaded.");
} catch (SQLException ex) {
System.out.println("Something is not good.");
}
}
的可能的复制[连接Java的MySQL数据库] (http://stackoverflow.com/questions/2839321/connect-java-to-a-mysql-database) –