首页 > 代码库 > SQLException: No suitable driver found for jdbc:mysql://localhost:3306/xxxx
SQLException: No suitable driver found for jdbc:mysql://localhost:3306/xxxx
刚刚学习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了
本文出自 “PHP学习” 博客,请务必保留此出处http://xtceetg.blog.51cto.com/5086648/1855379
SQLException: No suitable driver found for jdbc:mysql://localhost:3306/xxxx
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。