hibernate.cfg.xml 里面如下配置

<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>perty name="hibernate.c3p0.acquireRetryAttempts">30</property>

<property name="hibernate.c3p0.acquireIncrement">2</property>

<property name="hibernate.c3p0.checkoutTimeout">30000</property>  

<property name="hibernate.c3p0.idleConnectionTestPeriod">120</property>

<property name="hibernate.c3p0.maxIdleTime">180</property>

<property name="hibernate.c3p0.initialPoolSize">3</property>

<property name="hibernate.c3p0.maxPoolSize">50</property>

<property name="hibernate.c3p0.minPoolSize">1</property>

<property name="hibernate.c3p0.maxStatements">0</property>