hibernate連線mysql配置檔案
阿新 • • 發佈:2019-02-17
- <?xml version="1.0" encoding="GBK"?>
- <!-- 指定Hibernate配置檔案的DTD資訊 -->
- <!DOCTYPE hibernate-configuration PUBLIC
- "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
- <!-- hibernate- configuration是連線配置檔案的根元素 -->
- <hibernate-configuration
- <session-factory>
- <!-- 指定連線資料庫所用的驅動 -->
- <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
- <!-- 指定連線資料庫的url,hibernate連線的資料庫名 -->
- <property name="connection.url">jdbc:mysql://localhost/slim</property>
- <property name="connection.useUnicode"
- <property name="connection.characterEncoding">gbk</property>
- <!-- 指定連線資料庫的使用者名稱 -->
- <property name="connection.username">root</property>
- <!-- 指定連線資料庫的密碼 -->
- <property name="connection.password">gyfbao</property>
- <!-- C3P0連線池設定-->
- <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
- <!-- 指定連線池裡最大連線數 -->
- <property name="hibernate.c3p0.max_size">20</property>
- <!-- 指定連線池裡最小連線數 -->
- <property name="hibernate.c3p0.min_size">1</property>
- <!-- 指定連線池裡連線的超時時長 -->
- <property name="hibernate.c3p0.timeout">1800</property>
- <!-- 指定連線池裡最大快取多少個Statement物件 -->
- <property name="hibernate.c3p0.max_statements">100</property>
- <property name="hibernate.c3p0.idle_test_period">500</property>
- <property name="hibernate.c3p0.acquire_increment">2</property>
- <property name="hibernate.c3p0.validate">true</property>
- <property name="hibernate.c3p0.preferredTestQuery ">select 1 </property>
- <property name="hibernate.c3p0.idleConnectionTestPeriod ">18000</property>
- <property name="hibernate.c3p0.maxIdleTime">25000</property>
- <property name="hibernate.c3p0.testConnectionOnCheckout">true</property>
- <!-- 指定資料庫方言 -->
- <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
- <!-- 根據需要自動建立資料庫 -->
- <property name="hbm2ddl.auto">update</property>
- <!-- 顯示Hibernate持久化操作所生成的SQL -->
- <property name="show_sql">true</property>
- <!-- 將SQL指令碼進行格式化後再輸出-->
- <property name="hibernate.format_sql">true</property>
- <!-- 羅列所有的對映檔案
- <mapping resource="User.hbm.xml"/>
- <mapping resource="Area.hbm.xml"/>
- </session-factory>
- </hibernate-configuration>