您的位置:首页 > 数据库 > MySQL

hibernate连接mysql配置文件

2015-05-08 11:17 239 查看



<!-- 指定Hibernate配置文件的DTD信息-->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- hibernate- configuration是连接配置文件的根元素-->
<hibernate-configuration>
<session-factory>
<!-- 指定连接数据库所用的驱动-->
<propertyname="connection.driver_class">com.mysql.jdbc.Driver</property>
<!--指定连接数据库的url,hibernate连接的数据库名 -->
<propertyname="connection.url">jdbc:mysql://localhost/slim</property>
<propertyname="connection.useUnicode">true</property>
<propertyname="connection.characterEncoding">gbk</property>
<!-- 指定连接数据库的用户名-->
<propertyname="connection.username">root</property>
<!-- 指定连接数据库的密码-->
<propertyname="connection.password">gyfbao</property>
<!--C3P0连接池设定-->
<propertyname="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<!-- 指定连接池里最大连接数-->
<propertyname="hibernate.c3p0.max_size">20</property>
<!-- 指定连接池里最小连接数-->
<propertyname="hibernate.c3p0.min_size">1</property>
<!-- 指定连接池里连接的超时时长-->
<propertyname="hibernate.c3p0.timeout">1800</property>
<!--指定连接池里最大缓存多少个Statement对象 -->
<propertyname="hibernate.c3p0.max_statements">100</property>
<propertyname="hibernate.c3p0.idle_test_period">500</property>
<propertyname="hibernate.c3p0.acquire_increment">2</property>
<propertyname="hibernate.c3p0.validate">true</property>
<propertyname="hibernate.c3p0.preferredTestQuery ">select 1</property>
<propertyname="hibernate.c3p0.idleConnectionTestPeriod">18000</property>
<propertyname="hibernate.c3p0.maxIdleTime">25000</property>
<propertyname="hibernate.c3p0.testConnectionOnCheckout">true</property>

<!-- 指定数据库方言-->
<propertyname="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<!-- 根据需要自动创建数据库-->
<propertyname="hbm2ddl.auto">update</property>
<!-- 显示Hibernate持久化操作所生成的SQL-->
<propertyname="show_sql">true</property>
<!--将SQL脚本进行格式化后再输出-->
<propertyname="hibernate.format_sql">true</property>
<!-- 罗列所有的映射文件
<mappingresource="User.hbm.xml"/>
<mappingresource="Area.hbm.xml"/>
<mappingresource="Training.hbm.xml"/>
<mappingresource="School.hbm.xml"/>
<mappingresource="Figure.hbm.xml"/>
<mappingresource="Jobs.hbm.xml"/>
<mappingresource="Trabuy.hbm.xml"/>
<mappingresource="Schbuy.hbm.xml"/>
<mappingresource="Schfigure.hbm.xml"/>
<mappingresource="Profession.hbm.xml"/>
<mappingresource="Course.hbm.xml"/>
<mappingresource="Library.hbm.xml"/>
<mappingresource="MainCategories.hbm.xml"/>
<mappingresource="SecondaryCategories.hbm.xml"/>-->
<mappingresource="News.hbm.xml"/>
<mappingresource="NewContent.hbm.xml"/>
<mappingresource="Ask.hbm.xml"/>
<mappingresource="Answer.hbm.xml"/>
<mappingresource="About.hbm.xml"/>
<mappingresource="Item.hbm.xml"/>
</session-factory>
</hibernate-configuration>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: