Hibernate设置使用C3P0连接池
1.导入jar文件
2.修改hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?><!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration> <session-factory><property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property><property name="hibernate.c3p0.min_size">5</property><property name="hibernate.c3p0.man_size">10</property><property name="hibernate.c3p0.man_statements">50</property><property name="hibernate.c3p0.timeout">3600</property><property name="hibernate.c3p0.idle_test_period">120</property><property name="hibernate.c3p0.acquire_increment">2</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.HSQLDialect</property> <!-- Enable Hibernate's current session context --> <property name="current_session_context_class">org.hibernate.context.ManagedSessionContext</property> <!-- Disable the second-level cache --> <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property> <!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">create</property> <mapping resource="org/hibernate/tutorial/domain/Event.hbm.xml"/> </session-factory></hibernate-configuration>
?将这些配置加入到hibernate.cfg.xml配置文件中即可
?