hello, I have a problem, for all query and transactions, Im have too many connection sleep for long time, that connection dont close....
I using java persistence, mysql 5.0 and java1.6 and tomcat 5.5
example my DAO
public void saveCat(Cat cat) throws ServiceUnavailableException{
EntityManagerFactory emf = InitSessionFactoryManager.getEntityManagerFactory();
EntityManager em = emf.createEntityManager();
EntityTransaction et= em.getTransaction();
et.begin();
em.merge(cat);
et.commit();
em.close();
}
my hibernate.cfg.mxl
--------
<hibernate-configuration>
<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>
<!--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">5</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.timeout">5</property>
<property name="hibernate.connection.release_mode">after_transaction</property>
<!--cerrar automaticamente la sesion -->
<property name="hibernate.transaction.auto_close_session">true</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>
<mapping class="Cat"/>
</session-factory>
</hibernate-configuration>
my cp30.propeties
---------------------------
c3p0.maxConnectionAge=8
c3p0.maxIdleTimeExcessConnections=4
my class Cat
@Entity
@Table(name="Cat")
public class CallManager implements java.io.Serializable{
@Column(name="Name",columnDefinition="varchar(255)",nullable=false)
private String Name
public String getNane() {
return Name;
}
@OneToMany(fetch=FetchType.LAZY, mappedBy="cat", cascade= CascadeType.ALL)
@Cascade({org.hibernate.annotations.CascadeType.ALL})
private java.util.List<Food> foods;
public java.util.List<Food> getFoods) {
return this.foods;
}
}
what happening? what is wrong? helpme please, thankĀ“s
|