<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="connection.url">jdbc:mysql://localhost:3306/test</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.username">root</property> <property name="connection.password">root</property> <!--指定连接池里最大连接数--> <property name="hibernate.c3p0.max_size">20</property> <!--指定连接池里最小连接数--> <property name="c3p0.min_size">8</property> <!--指定连接池里连接的超时时长--> <property name="hibernate.c3p0.timeout">5000</property> <!--指定连接池里最大缓存多少个Statement对象--> <property name="hibernate.c3p0.max_statements">100</property> <property name="hibernate.c3p0.idle_test_period">3000</property> <property name="hibernate.c3p0.acquire_increment">2</property> <property name="hibernate.c3p0.validate">true</property> <!-- 指定数据库方言--> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- 根据需要自动创建数据表--> <property name="hibernate.hbm2ddl.auto">update</property> <!--设置二级缓存--> <property name="hibernate.cache.provider_class">org.hibernate.CacheMode</property> <!--控制台输出hibernate生成的sql--> <property name="hibernate.show_sql">true</property> <!--将sql语句转成良好的sql--> <property name="hibernate.format_sql">true</property> <!--设置是否自动提交,通常不建议打开自动提交--> <property name="hibernate.connection.autocommit">false</property>
<!-- 罗列所有的映射文件--> <mapping resource="hibernate/News.hbm.xml"/> </session-factory> </hibernate-configuration>