-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Help me please, too many connection "sleep"
PostPosted: Fri Oct 12, 2007 9:19 pm 
Newbie

Joined: Fri Oct 12, 2007 8:47 pm
Posts: 5
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 Cat 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


Last edited by arianna on Mon Oct 15, 2007 1:07 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: probably need to fix pool setting
PostPosted: Mon Oct 15, 2007 12:40 pm 
Newbie

Joined: Mon Oct 15, 2007 12:36 pm
Posts: 5
We use Apache dbcp for our connection provider, which allows you to specify a so-called "validation query". This query (as I understand it) is used as a keep-alive for connections to avoid the problem you are seeing. Look at your c3p0 configuration, maybe they have a similar feature. I doubt that your Hibernate config is the issue here.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 10:07 pm 
Newbie

Joined: Fri Oct 12, 2007 8:47 pm
Posts: 5
I think the problem is the relationship mapping....
Idon´t know to fix the problem


the class has one to many relationship, maybe the too many connection sleep are caused by relationship mapping.

any idea to fix de problem?
thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 04, 2007 7:53 am 
Newbie

Joined: Tue Dec 04, 2007 7:46 am
Posts: 2
The same problem appeared in my application after migrating java to 1.6

Try switching back to jdk1.5. might help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.