天宇的JAVA空间站


hibernate c3p0连接池的配置

07-06-05 10:20Update

LifevV.COM编辑部

c3p0为open source的JDBC连接池,随hibernate一起发布。本文介绍了怎么在hibernate里配置使用c3p0。

c3p0连接池的配置非常简单,只需要在hibernate.cfg.xml里增加:

        <!-- configuration pool -->
        <property name="c3p0.acquire_increment">1</property>
        <property name="c3p0.idle_test_period">100</property> <!-- seconds -->
        <property name="c3p0.max_size">5</property>
        <property name="c3p0.max_statements">0</property>
        <property name="c3p0.min_size">2</property>
        <property name="c3p0.timeout">90</property> <!-- seconds -->

另外,还需要在CLASS_PATH里加上c3p0-x.x.x.jar文件(x.x.x为版本号),c3p0-x.x.x.jar文件随hibernate一起发布,你可以在其lib目录下找到该文件。

配置好之后,hibernate便会自动使用c3p0的连接池:C3P0ConnectionProvider
 
Copyright ©2006-2010 lifevv.com. All Rights Reserved
POWERED BY @pmplat.syboos.com