SQLException: No suitable driver found for jdbc:mysql://localhost:3306/xxxx
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章
出现java.sql.SQLException: No suitable driver的几种解决办法
出现java.sql.SQLException: No suitable driver的几种解决办法
java连接sql server 2005的问题 java.sql.SQLException: No suitable driver
java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default
运行时报java.sql.SQLException: No suitable driver的几种解决办法
异常java.sql.SQLException: No suitable driver found for jdbc://mysql://hadoop001:3306/xxx