Hi,
Hibernate run out of the pool connection limit. I really dont know why. My feeling is , i have a problem with the SessionFactory maybe.
Because each time a call the servlet, i see the INFO of the configuration loading.
I went back on a very simple configuration and it's always the case :
Example of my configuration file :
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="connection.pool_size">5</property>
<!-- <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> -->
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Test -->
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.transaction.auto_close_session">true</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- this will show us all sql statements -->
<property name="hibernate.show_sql">false</property>
Example of on of my Dao class ( All of them follow this model ) :
Code:
public class BSban {
Session session;
public BSban(){}
public void createBan(Ban b){
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
try{
session.beginTransaction();
session.save(b);
session.getTransaction().commit();
}
catch (RuntimeException e) {
session.getTransaction().rollback();
}
}
}
I have to deploy my application in production in few day and i cant due to this problem , i look for a solution since 2 days, i found nothing about this problem on google :-(
Thanks
After read that :
When all mappings have been parsed by the org.hibernate.cfg.Configuration, the application must obtain a factory for org.hibernate.Session instances. This factory is intended to be shared by all application threads:
SessionFactory sessions = cfg.buildSessionFactory();
Hibernate does allow your application to instantiate more than one org.hibernate.SessionFactory. This is useful if you are using more than one database.
It's confirme my feeling , i am not suppose to see a load of hbm file at each request send to my servlet. But i use the singleton factory of hibernate. Something clear the static attribute of my Singletong factory ....
I dont know why ...