I using tomcat  5.5 with java persistence,hibernate 3.2  and c3p0 -0.9.12,
mysql 5.0.
I have a pool connection with cp30 .  All transactions and querys has too many connections "sleep" for long time. this conecction don't close.
what's happening? what fix?
persistence.xml
-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- example of reference to a cfg.xml file -->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd" version="1.0">
<persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
        
    <properties>
        <property name="hibernate.max_fetch_depth" value="3"/>
        <!-- alternatively to <class> and <property> declarations, you can use a regular hibernate.cfg.xml file -->
         <property name="hibernate.ejb.cfgfile" value="/mx/com/nextiraone/tarificador/hibernate/config/hibernate.cfg.xml"/>
           <property name="toplink.jdbc.read-connections.max" value="3"/>
            <property name="toplink.jdbc.read-connections.min" value="1"/>
            <property name="toplink.jdbc.write-connections.max" value="5"/>
            <property name="toplink.jdbc.write-connections.min" value="2"/>
     </properties>
   </persistence-unit>
</persistence>
hibernate.cfg.xml
-------------------------------
<?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">
<!--
    Document   : hibernate.cfg.xml.xml
    Created on : 11 de septiembre de 2007, 11:54 AM
    Author     : arobles
    Description:
        Purpose of the document follows.
-->
<hibernate-configuration>
    
    <session-factory>
        
        <!-- Database connection settings -->
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/tarificador</property>
        <property name="connection.username">arianna</property>
        <property name="connection.password">12345</property>
        
        
        
        <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>   
       
        <!--  thread is the short name for      org.hibernate.context.ThreadLocalSessionContext      and let Hibernate bind the session automatically to the thread    -->    
        <property name="current_session_context_class">thread</property>    
       
        <!-- JDBC connection pool (use the built-in) -->
        <!-- 
        <property name="connection.pool_size">3</property>
-->
<!--manejo de conexiones -->
<property name="hibernate.c3p0.acquire_increment">1</property> 
<property name="hibernate.c3p0.idle_test_period">2</property> 
<property name="hibernate.c3p0.max_size">50</property> 
<property name="hibernate.c3p0.min_size">1</property> 
<property name="hibernate.c3p0.timeout">5</property> 
<!--cerrar automaticamente la sesion -->
<property name="hibernate.transaction.auto_close_session">true</property> 
<property name="hibernate.connection.release_mode">after_transaction</property>
        
        
        
        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        
        <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
        <property name="org.hibernate.flushMode">org.hibernate.FlushMode.AUTO</property>
        
        
        
        
        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>
        
        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>
        
     class="mx.com.nextiraone.tarificador.business.object.Usuario"/>
             <!--   
        <class-cache class="org.hibernate.ejb.test.Item" usage="read-write"/>
        <collection-cache collection="org.hibernate.ejb.test.Item.distributors" usage="read-write" region="RegionName"/>
         -->   
        
    </session-factory>
    
</hibernate-configuration>
c3p0.properties
-----------------------------
c3p0.maxConnectionAge=8
c3p0.maxIdleTimeExcessConnections=4
Dao example
 public List findUsuariosWithStatusAndIdUserCallManager(Integer usuarioEstatus, String Id_usuario_call_manager) throws ServiceUnavailableException{
        EntityManagerFactory emf =InitSessionFactoryManager.getEntityManagerFactory();
        EntityManager em = emf.createEntityManager();
        //em.getTransaction().begin();
        Query query = em.createQuery(
                " from  " +
                " Usuario as usuario " +
                "  where  " +
                " usuario.Estatus = :Estatus  and"+
                " usuario.Id_usuario_call_manager = :Id_usuario_call_manager");
        query.setParameter("Estatus",usuarioEstatus);
        query.setParameter("Id_usuario_call_manager",Id_usuario_call_manager);
        List l=query.getResultList();
        em.close();
          // emf.close();
       return l;
    }
public void saveUsuario(Usuario usuario) throws ServiceUnavailableException{
        EntityManagerFactory emf = InitSessionFactoryManager.getEntityManagerFactory();
        EntityManager em = emf.createEntityManager();
        EntityTransaction et= em.getTransaction();
        et.begin();
        em.merge(usuario);
        et.commit();
        em.close();
          // emf.close();
    }
-------------------
class example
import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import org.hibernate.annotations.Cascade;
@Entity
@Table(name="Usuario")
public class Usuario implements java.io.Serializable {
      // <editor-fold defaultstate="collapsed" desc=" Property:   String Nombre ">
    @Column(name="Nombre",columnDefinition="varchar(255)",nullable=true)
    private String Nombre;
    public String getNombre() {
        return Nombre;
    }
    public void setNombre(String Nombre) {
        this.Nombre = Nombre;
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc=" Property:   String Apellido ">
    @Column(name="Apellido",columnDefinition="varchar(255)",nullable=true)
    private String Apellido;
    public String getApellido() {
        return Apellido;
    }
    public void setApellido(String Apellido) {
        this.Apellido = Apellido;
    }
    // </editor-fold>
    
      // <editor-fold defaultstate="collapsed" desc=" PrimaryKey:   int Usuario_id ">
    @Id
    @GeneratedValue
    @Column(name="Usuario_id",columnDefinition="int",nullable=false)
    private Integer Usuario_id;
    
    public Integer getUsuario_id() {
        return Usuario_id;
    }
    public void setUsuario_id(Integer Usuario_id) {
        this.Usuario_id = Usuario_id;
    }
    //</editor-fold>
   
    // <editor-fold defaultstate="collapsed" desc=" 1-N  Relation to Collection /*Usuario*/ subordinados ">
    @OneToMany(mappedBy="jefe")
    private java.util.List<Usuario> subordinados;
    
    public java.util.List<Usuario> getSubordinados() {
        return this.subordinados;
    }
    
    public void setSubornidados(java.util.List<Usuario> subordinados) {
        this.subordinados = subordinados;
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc=" N-1  Relation to Usuairo jefe ">
    @ManyToOne(optional=true, cascade={CascadeType.MERGE,CascadeType.PERSIST})
    @JoinColumn(name="Usuario_jefe_id",nullable=true)
    private Usuario jefe;
    
    public Usuario getJefe() {
        return this.jefe;
    }
    
    public void setJefe(Usuario jefe) {
        this.jefe= jefe;
    }
    // </editor-fold>
    
       // <editor-fold defaultstate="collapsed" desc=" N-1  Relation to Perfil perfil ">
    @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
    @JoinColumn(name="Perfil_id", nullable=true)
    private Perfil perfil;
    
    public Perfil getPerfil() {
        return this.perfil;
    }
    
    public void setPerfil(Perfil perfil) {
        this.perfil = perfil;
    }
    // </editor-fold>
 
    // <editor-fold defaultstate="collapsed" desc=" N-1  Relation to Departamento departamento ">
    @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
     @JoinColumn(name="Departamento_id")
    private Departamento departamento;
    
    public Departamento getDepartamento() {
        return this.departamento;
    }
    
    public void setDepartamento(Departamento departamento) {
        this.departamento = departamento;
    }
    // </editor-fold>
   
    // <editor-fold defaultstate="collapsed" desc=" N-1  Relation to Centro_Costo centro_Costo ">
    @ManyToOne( optional=true, cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
    @JoinColumn(name="Centro_costo_id", nullable=true)
    private Centro_Costo centro_Costo;
    
    public Centro_Costo getCentro_Costo() {
        return this.centro_Costo;
    }
    
    public void setCentro_Costo(Centro_Costo centro_Costo) {
        this.centro_Costo = centro_Costo;
    }
    // </editor-fold>
}