开发者

database connection ClassNotfoundException

Whenever I execute开发者_开发知识库 my code for accessing a database I get the following error:

:java.lang.ClassNotFoundException: com.mysql.jdbc.DriverError :java.lang.ClassNotFoundException: com.mysql.jdbc.Driver


You don't have the mysql connector added to your project. See this page for more information: http://dev.mysql.com/usingmysql/java/1

Edit:

If you are using netbeans, just right click on the library folder of your project, and then select the option 'add library'. You will find the 'MySQL JDBC Driver' library, select this library and click on 'Add library'.


You have to add the driver you mentioned in your classpath. If you're using maven then you need to include the following dependency in your POM file.

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.14</version>
  <scope>runtime</scope>
</dependency>

Otherwise you have to download manually the Connector J from http://dev.mysql.com/downloads/mirror.php?id=13597#mirrors


This blog may be helpful: SuaveSnippets: JDBC and MySQL, ClassNOTFoundException

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜