Não estou conseguindo conectar com o banco
public class JPAUtil {
private static final EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("cine_synergy");
public static EntityManager getEntityManager() {
return entityManagerFactory.createEntityManager();
}
public static void closeEntityManager() {
entityManagerFactory.close();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2"
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_2.xsd">
<persistence-unit name="cine_synergy"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>br.com.review.model.entities.Usuario</class>
<class>br.com.review.model.entities.Series</class>
<class>br.com.review.model.entities.Filmes</class>
<class>br.com.review.model.entities.Avaliacoes</class>
<properties>
<property name="javax.persistence.jdbc.driver"
value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://localhost/cine_synergy?createDatabaseIfNotExist=true" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password"
value="root" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
public class UsuarioRepository {
public void cadastrarUsuario(Usuario usuario) {
EntityManager manager = JPAUtil.getEntityManager();
EntityTransaction transaction = manager.getTransaction();
try {
transaction.begin();
manager.persist(usuario);
transaction.commit();
} catch (Exception e) {
if(transaction.isActive()) {
transaction.rollback();
}
} finally {
if(transaction.isActive()) {
manager.close();
}
}
}