简体   繁体   中英

About c3p0 and hibernate

I write a hibernate.cfg.xml file almost the same from hibernate books like:

<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.connection.password">**</property>
<property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/db</property>
<property name="hibernate.connection.username">**</property>

<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">30</property>
<property name="c3p0.time_out">1800</property>
<property name="c3p0.max_statement">50</property>
<!--property name="show_sql">true</property-->
<property name="format_sql"> true</property>

But this seems actually c3p0 is not used. When I do test to establish 1000 sessions, it tries to establish 1000 connections.

Could anyone please give me some hint about this? Thank you

Looking at your configuration file seems that you are missing one key property

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

Try setting this property and see if this turns things around for you or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM