- 1 <?xml version="1.0" encoding="UTF-8"?>
- 2 <!-- DTD是约束,可以在核心包里面找 -->
- 3 <!DOCTYPE hibernate-configuration PUBLIC 4"-//Hibernate/Hibernate Configuration DTD 3.0//EN" 5"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
- 6
- 7 <hibernate-configuration>
- 8 <session-factory>
- 9
- 10 <!-- 连接数据库的信息 -->
- 11 <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
- 12 <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/spring_struts2</property>
- 13 <property name="hibernate.connection.username">root</property>
- 14 <property name="hibernate.connection.password">123456</property>
- 15
- 16 <!-- hibernate的配置信息 -->
- 17 <!-- 配置数据库的方言,根据底层的数据库生成不同的SQL -->
- 18 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
- 19 <!-- 配置显示SQL -->
- 20 <property name="hibernate.show_sql">true</property>
- 21 <!-- 配置格式化SQL -->
- 22 <property name="hibernate.format_sql">true</property>
- 23 <!-- 配置hbm2ddl -->
- 24 <property name="hibernate.hbm2ddl.auto">create</property>
- 25
- 26 <!-- 配置C3P0连接池 -->
- 27 <!-- 注意这个类要配置进去 -->
- 28 <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
- 29 <!--在连接池中可用的数据库连接的最少数目 -->
- 30 <property name="c3p0.min_size">5</property>
- 31 <!--在连接池中所有数据库连接的最大数目 -->
- 32 <property name="c3p0.max_size">20</property>
- 33 <!--设定数据库连接的过期时间,以秒为单位,如果连接池中的某个数据库连接处于空闲状态的时间超过了timeout时间,就会从连接池中清除 -->
- 34 <property name="c3p0.timeout">120</property>
- 35 <!--每3000秒检查所有连接池中的空闲连接 以秒为单位-->
- 36 <property name="c3p0.idle_test_period">3000</property>
- 37
- 38 <!-- 设置jdbc的隔离级别 -->
- 39 <property name="hibernate.connection.isolation">4</property>
- 40
- 41 <!-- 加载映射文件 -->
- 42 <mapping resource="com/ssh/domain/user.hbm.xml" />
- 43
- 44 </session-factory>
- 45 </hibernate-configuration>
来源: http://www.bubuko.com/infodetail-1966286.html