Skip to content

Instantly share code, notes, and snippets.

@MangoLiu
Last active January 1, 2016 21:39
Show Gist options
  • Save MangoLiu/8205353 to your computer and use it in GitHub Desktop.
Save MangoLiu/8205353 to your computer and use it in GitHub Desktop.
hibernate.cfg.xml (hibernate配置文件)
<?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文件头都一样-->
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 指定的数据库的url,hibernate连接数据库名,具体而定。 -->
<property name="connection.url">dbc:mysql://localhost:3306/countmanagement</property>
<property name="connection.characterEncoding">GBK</property>
<property name="connection.username">root</property>
<property name="connection.password">1234</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="myeclipse.connection.profile">mysql</property>
<!-- 配置C3P0连接池 -->
<property name="connection.provider_class">
org.hibernate.connection.C3P0ConnectionProvider
</property>
<property name="c3p0.max_size">20</property>
<property name="c3p0.min_size">3</property>
<property name="c3p0.timeout">120</property>
<property name="c3p0.max_statements">100</property>
<property name="c3p0.idle_test_period">120</property>
<property name="c3p0.acquire_increment">2</property>
<!-- 当连接池用完时,C3P0每次新增的连接数目 -->
<mapping resource="com/chinasoft/hiberinate/classname.hbm.xml" />
<!-- 以下省略一些其他配置... -->
</session-factory>
</hibernate-configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment