在 hibernate.cfg.xml 中加入如下代码
< property name ="hibernate.connection.provider_class" > org.hibernate.connection.C3P0ConnectionProvider </ property > < property name ="hibernate.c3p0.min_size" > 8 </ property > < property name ="hibernate.c3p0.max_size" > 200 </ property > < property name ="hibernate.c3p0.timeout" > 600 </ property > < property name ="hibernate.c3p0.max_statements" > 0 </ property > < property name ="hibernate.c3p0.idle_test_period" > 60 </ property > < property name ="hibernate.c3p0.acquire_increment" > 2 </ property > < property name ="hibernate.c3p0.validate" > true </ property >