I am using JSF in a college subject and the teacher has passed an activity. But I'm not able to write information from a form. The connection is done, I can perform up to JPQ queries direct from Netbeans, but when I try to write information entered by a form the following error appears:
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.lang.ClassCastException: java.math.BigInteger can not be cast to java.lang.Long Error Code: 0
I'm using the Java connector v5.1.47. When I try to use a more up-to-date connector I can not connect to the database. Even with MySQL configured not to use encryption in the root password. Because when I used it, the connection was not made because of this encryption.
Update
Here is my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="RestManagerPU" transaction-type="JTA">
<jta-data-source>java:app/RestManager</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
And here's DAOHelper, where the error occurs:
*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DAO;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
/**
*
* @author leand
*/
public class DAOHelper {
public EntityManager getEM(){
EntityManagerFactory emf = Persistence.createEntityManagerFactory("RestManagerPU");
return emf.createEntityManager();
}
}
The error occurs on the line:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("RestManagerPU");