[RESOLVIDO] Configuração C3P0 Hibernate 3.5

1 resposta
Guitar_Men

Pessoal, tenho uma aplicação console que utiliza o Hibernate para persistência. Transformei a danada em serviço pelo Java Service Wrapper e deixei rodando no server. Depois de 2 dias fui verificar o log do hibernate e tinha o seguinte:

[ERROR] - JDBCExceptionReporter - The last packet successfully received from the server was161468 seconds ago.The last packet sent successfully to the server was 161468 seconds ago, which  is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

Meu hibernate config está configurado para trabalhar com o C3p0 (Pelo menos eu acho) segue o mesmo:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <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">xxxxxxxxxxxx</property>
    <property name="hibernate.connection.username">xxxxxxxxx</property>
    <property name="hibernate.show_sql">false</property>
    <property name="hibernate.connection.password">xxxxxxxxxxxx</property>
    <property name="hibernate.c3p0.acquire_increment">1</property>
    <property name="hibernate.c3p0.idle_test_period">100</property>
    <property name="hibernate.c3p0.max_size">100</property>
    <property name="hibernate.c3p0.max_statements">0</property>
    <property name="hibernate.c3p0.min_size">10</property>
    <property name="hibernate.c3p0.timeout">100</property>
    <property name="hibernate.connection.autocommit">false</property>
    
	<mapping class="xxxxxxxxxxxxxxxxxxxxx"/>
  </session-factory>
</hibernate-configuration>

Perguntas:
1 - Como ter certeza que a conexão esta sendo feita e gerenciada pelo C3P0 ?
2 - Alguém ja teve esse problema ?? Realmente preciso alterar a configuração mencionada no erro ??

Valew pessoal

1 Resposta

Guitar_Men

Acho que resolvi o problema da reconexão. Faltou um parâmetro para habilitar o C3p0 (que não consta na documentação oficial)

<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

Vi isso aqui

Criado 3 de agosto de 2010
Ultima resposta 4 de ago. de 2010
Respostas 1
Participantes 1