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
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