Question

I receive exception when my web project tries to connect database.

Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException Exception Description: Configuration error. Class [com.mysql.jdbc.Driver] not found.at org.eclipse.persistence.exceptions.DatabaseException.configurationErrorClassNotFound(DatabaseException.java:82)

My persistence.xml is like this:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="flashpoll">
<class>entities.Question</class>
<class>entities.Poll</class>
<class>entities.User</class>
<class>entities.Answers</class>
<class>entities.Admin</class>
<properties>
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/flashpoll"/>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
        <property name="javax.persistence.jdbc.password" value="12345"/>
        <property name="javax.persistence.jdbc.user" value="root" />
        <property name="eclipselink.ddl-generation" value="create-tables" />
        <property name="eclipselink.persistence-context.flush-mode" value="COMMIT" />
    </properties>
</persistence-unit>
</persistence>

mysql-connector-5.0.8 is also included in the libraries of the project. Any idea why do I still receive this Class [com.mysql.jdbc.Driver] not found error? Thanks for any help.

Was it helpful?

Solution

When creating web applications, your libraries (jars) should be placed inside WEB-INF/lib folder in order to be recognized by the web application server (Tomcat, JBoss, GlassFish, etc). Just copy/paste your mysql driver and other third party libraries inside this folder and redeploy your application.

OTHER TIPS

I just had the same problem. So, you must go in to your java project, right click in this, and go to property. In library copy and paste your mysql_connector_java_bin.jar as the jar file. You can find this in: "C:\Program Files\NetBeans 8.0.2\ide\modules\ext" for example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top