HI, I am using JPAContainer to connect with MySQL database.
- I have included ConnectorJ with MySQL in the library and under the folder of WEB-INF/lib, please see attachment file.
- Anyone has the same problem and knows how to solve it?
- when I use the same code and persistence file in another project it works fine. but with this project it gives me
javax.persistence.PersistenceException: Exception [EclipseLink-4003]
(Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [com.mysql.jdbc.Driver]
not found.
- Here is my code
package com.example.displaydatabase;
import javax.persistence.PersistenceContext;
import javax.servlet.annotation.WebServlet;
import com.howinecafe.bean.MemberBean;
import com.vaadin.addon.jpacontainer.JPAContainer;
import com.vaadin.addon.jpacontainer.JPAContainerFactory;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@PersistenceContext(name=“persistence/em”,unitName=“MEMBERBEAN”)
@SuppressWarnings(“serial”)
@Theme(“displaydatabase”)
public class DisplaydatabaseUI extends UI {
public static final String PERSISTENCE_UNIT = "MEMBERBEAN";
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = DisplaydatabaseUI.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
JPAContainer<MemberBean> memberContainer = JPAContainerFactory.make(MemberBean.class,"MEMBERBEAN");
Table myTable = new Table("This is my Table",memberContainer);
myTable.setSelectable(true);
myTable.setImmediate(true);
layout.addComponent(myTable);
}
}
- Persistence File
<persistence-unit name="MEMBERBEAN">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.jdbc.platform"
value="org.eclipse.persistence.platform.database.MySQLPlatform" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/howine_db"/>
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="1025ho" />
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
</properties>
21101.bmp (5.93 MB)