Pessoal,
Estou desenvolvendo uma aplicação Java Web utilizando o Hibernate para persistir os dados no MySQL. No momento de realizar o teste da conexão com o hibernate pela class main, é exibido o seguinte erro no console:
Arquivo hibernate.cfg.xml
?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<mapping class="br.com.geovane.controle.Pessoa" />
<mapping class="br.com.geovane.controle.PF" />
<mapping class="br.com.geovane.controle.PJ" />
<mapping class="br.com.geovane.controle.DocReceita" />
<mapping class="br.com.geovane.controle.CPF" />
<mapping class="br.com.geovane.controle.CNPJ" />
<mapping class="br.com.geovane.controle.Telefone" />
<mapping class="br.com.geovane.controle.Endereco" />
<mapping class="br.com.geovane.controle.Animal" />
<mapping class="br.com.geovane.controle.Cachorro" />
<mapping class="br.com.geovane.controle.Gato" />
<mapping class="br.com.geovane.controle.Servico" />
<mapping class="br.com.geovane.controle.Banho" />
<mapping class="br.com.geovane.controle.Consulta" />
<mapping class="br.com.geovane.controle.Tosa" />
<mapping class="br.com.geovane.controle.Vacina" />
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/estimacao</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.pool_size">10</property>
<property name="hibernate.hbm2dll.auto">create</property>
</session-factory>
</hibernate-configuration>
Classe ConexaoHibernate.java
static {
try {
sessionFactory = new AnnotationConfiguration().configure("hibernate.cfg.xml").buildSessionFactory();
} catch (Throwable e) {
System.err.println("\n\n\n ----------- Erro na fábrica de sessões Hibernate ---------------- \n\n\n");
e.printStackTrace();
System.err.println("\n\n\n ----------- Fim dos erros na fábrica de sessões Hibernate ------- \n\n\n");
throw new ExceptionInInitializerError(e);
}
}
//Retorna uma sessão de comunicação com o Banco de Dados
public static Session getInstance() {
Session session = (Session) threadLocal.get();
session = sessionFactory.openSession();
threadLocal.set(session);
return session;
}
Chamada na classe principal:
public static void main(String[] args) {
GerarTabelas();
}
private static void GerarTabelas() {
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.configure("hibernate.cfg.xml");
SchemaExport sx = new SchemaExport(cfg);
sx.create(true, true);
}
Pesquisei sobre esse problema, no entanto não consegui resolver. Se puderem ajudar, ficarei grato!