java中myeclipse连接mysql问题(java.lang.ClassNotFoundException: com.mysql.jdbc.Driver)

java中myeclipse连接mysql问题(java.lang.ClassNotFoundException: com.mysql.jdbc.Driver)
1、往项目中添加mysql-connector-java-5.0.8-bin.jar。驱动jar包;(右击项目buildpath——》add)
2、 String driver = "com.mysql.jdbc.Driver";
// URL指向要访问的数据库名
String url = "jdbc:mysql://127.0.0.1:3306/sxu_art_group";
String user = "root";
String password = "";
Class.forName(driver);
try {
// 加载驱动程序
Class.forName(driver);
// 连续数据库
Connection conn = DriverManager.getConnection(url, user, password);
if(!conn.isClosed()){
System.out.println("Succeeded connecting to the Database!");
}
// statement用来执行SQL语句
Statement statement = conn.createStatement();
// 要执行的SQL语句
String sql = "select * from student";
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
原文地址:https://www.cnblogs.com/RuMengkai/p/6230977.html