Olá amigos, pesquisei em vários lugares, porem não consegui resolver o erro abaixo. Estou utilizando Maven e MySql. Se alguém poder me ajudar eu agradeço.
ERRO:
mai 01, 2016 5:48:59 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.1.0.Final}
mai 01, 2016 5:48:59 PM org.hibernate.cfg.Environment
INFO: HHH000206: hibernate.properties not found
mai 01, 2016 5:48:59 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
mai 01, 2016 5:48:59 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
mai 01, 2016 5:48:59 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
INFO: HHH010002: C3P0 using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/KnowledgeBaseSystem
mai 01, 2016 5:48:59 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
INFO: HHH10001001: Connection properties: {user=root, password=****}
mai 01, 2016 5:48:59 PM org.hibernate.c3p0.internal.C3P0ConnectionProvider configure
INFO: HHH10001003: Autocommit mode: false
Falha ao tentar criar o SessionFactory. Erro: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Exception in thread “main” java.lang.NullPointerException
at com.conexao.teste.ConectaHibernateMySQL.main(ConectaHibernateMySQL.java:14)
HIHERNATE.CFG.XML:
<?xml version="1.0" encoding="UTF-8"?> org.gjt.mm.mysql.Driver root jdbc:mysql://localhost:3306/KnowledgeBaseSystem root org.hibernate.dialect.MySQL5InnoDBDialect <property name="hibernate.connection.pool_size">1</property>
<property name="hibernate.current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="hibernate.cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
<property name="hibernate.c3po.min_size">5</property>
<property name="hibernate.c3po.max_size">20</property>
<property name="hibernate.c3po.timeout">300</property>
<property name="hibernate.c3po.max_statements">50</property>
<property name="hibernate.c3po.idle_test_period">3000</property>
<property name="hibernate.c3p0.unreturnedConnectionTimeout">40</property>
<property name="hibernate.c3p0.debugUnreturnedConnectionStackTraces">true</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="generate_statistics">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping class="com.usuario.bean.Usuarios" />
</session-factory>
package com.usuario.bean;
import java.sql.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = “Usuarios”)
public class Usuarios {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name = "NOME", length = 50, nullable = false)
private String nome;
@Column(name = "CELULA", length = 5, nullable = false)
private String celula;
@Column(name = "CLIENTE", length = 50, nullable = false)
private String cliente;
@Column(name = "CARGO", length = 50, nullable = false)
private String cargo;
@Column(name = "EMAIL", length = 50, nullable = false)
private String email;
@Column(name = "SENHA", length = 25, nullable = false)
private String senha;
@Basic(optional = false)
@Column(name = "DATA", insertable = false, updatable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date data;
public class HibernateUtil {
private static final SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
Configuration configuration = new Configuration();
configuration.configure("hibernate.cfg.xml");
return configuration.buildSessionFactory();
} catch (Throwable ex) {
System.out.println("Falha ao tentar criar o SessionFactory. Erro: " + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}