hibernate4配置文件hibernate.cfg.xml配置详解
<?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE hibernate-configuration PUBLIC
3 "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
4 "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
5 <hibernate-configuration>
6
7 <session-factory>
8 <property name="connection.url">jdbc:oracle:thin:@127.0.0.1:1521:orcl</property>
9 <property name="connection.username">username</property>
10 <property name="connection.password">password</property>
11 <!-- 数据库JDBC驱动类名 -->
12 <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
13 <!-- 数据库方言 -->
14 <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
15 <!-- ddl语句自动建表 -->
16 <property name="hbm2ddl.auto">none</property>
17 <property name="show_sql">true</property>
18 <property name="format_sql">true</property>
19
20 <!-- 连接池配置 -->
21 <property name="hibernate.connection.provider_class">
22 org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
23 </property>
24 <!-- 连接池中JDBC连接的最小数量。Hibernate默认为1 -->
25 <property name="hibernate.c3p0.min_size">5</property>
26 <!-- 连接池中JDBC连接的最大数量。Hibernate默认为100 -->
27 <property name="hibernate.c3p0.max_size">20</property>
28 <!-- 何时从连接池中移除一个空闲的连接(以秒为单位)时。Hibernate默认为0,永不过期 -->
29 <property name="hibernate.c3p0.timeout">300</property>
30 <!-- 被缓存的预编译语句数量。用来提高性能。Hibernate默认为0,缓存不可用-->
31 <property name="hibernate.c3p0.max_statements">100</property>
32 <!-- 一个连接被自动验证前的闲置时间(以秒为单位)。Hibernate默认为0 -->
33 <property name="hibernate.c3p0.idle_test_period">3000</property>
34
35 <!-- 注册ORM映射文件 -->
36 <mapping class="com....." />
37
38 </session-factory>
39 </hibernate-configuration>