您的位置:首页 > 产品设计 > UI/UE

SQLException: No suitable driver found for jdbc:mysql://localhost:3306/xxxx

2016-09-22 13:00 851 查看
刚刚学习jsp,对着视频敲代码,报这个错误。
SQLException: No suitable driver found for jdbc:mysql://localhost:3306/shop
SQLState: 08001
VendorError: 0
问题,因为没有引入Driver类。
final String DBDRIVER = "org.gjt.mm.mysql.Driver";
String username = "root";
String password = "root";
String url = "jdbc:mysql://localhost:3306/shop";
Connection con = null;
try {
Class.forName(DBDRIVER);
con = DriverManager.getConnection(url, username, password);
} catch (SQLException e) {
System.out.println("SQLException: " + e.getMessage());
System.out.println("SQLState: " + e.getSQLState());
System.out.println("VendorError: " + e.getErrorCode());
} catch (ClassNotFoundException e) {
System.out.println("Class:" + e.getMessage());
}
加上Class.forName("xxxx")就OK了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  found jdbc driver
相关文章推荐