hibernate连接mysql配置文件

[html]  view plain copy
  1. <?xml version="1.0" encoding="GBK"?>  
  2. <!-- 指定Hibernate配置文件的DTD信息 -->  
  3. <!DOCTYPE hibernate-configuration PUBLIC  
  4.  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"  
  5.  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">  
  6. <!-- hibernate- configuration是连接配置文件的根元素 -->  
  7. <hibernate-configuration>  
  8.  <session-factory>  
  9.   <!-- 指定连接数据库所用的驱动 -->  
  10.   <property name="connection.driver_class">com.mysql.jdbc.Driver</property>  
  11.   <!-- 指定连接数据库的url,hibernate连接的数据库名 -->  
  12.   <property name="connection.url">jdbc:mysql://localhost/slim</property>  
  13.   <property name="connection.useUnicode">true</property>  
  14.   <property name="connection.characterEncoding">gbk</property>  
  15.   <!-- 指定连接数据库的用户名 -->  
  16.   <property name="connection.username">root</property>  
  17.   <!-- 指定连接数据库的密码 -->  
  18.   <property name="connection.password">gyfbao</property>  
  19.   <!-- C3P0连接池设定-->  
  20.   <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>  
  21.   <!-- 指定连接池里最大连接数 -->  
  22.   <property name="hibernate.c3p0.max_size">20</property>  
  23.   <!-- 指定连接池里最小连接数 -->  
  24.   <property name="hibernate.c3p0.min_size">1</property>  
  25.   <!-- 指定连接池里连接的超时时长 -->  
  26.   <property name="hibernate.c3p0.timeout">1800</property>  
  27.   <!-- 指定连接池里最大缓存多少个Statement对象 -->  
  28.   <property name="hibernate.c3p0.max_statements">100</property>  
  29.   <property name="hibernate.c3p0.idle_test_period">500</property>  
  30.   <property name="hibernate.c3p0.acquire_increment">2</property>  
  31.   <property name="hibernate.c3p0.validate">true</property>  
  32.   <property name="hibernate.c3p0.preferredTestQuery ">select 1 </property>  
  33.   <property name="hibernate.c3p0.idleConnectionTestPeriod ">18000</property>             
  34.   <property name="hibernate.c3p0.maxIdleTime">25000</property>          
  35.   <property name="hibernate.c3p0.testConnectionOnCheckout">true</property>  
  36.     
  37.   <!-- 指定数据库方言 -->  
  38.   <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>  
  39.   <!-- 根据需要自动创建数据库 -->  
  40.   <property name="hbm2ddl.auto">update</property>  
  41.   <!-- 显示Hibernate持久化操作所生成的SQL -->  
  42.   <property name="show_sql">true</property>  
  43.   <!-- 将SQL脚本进行格式化后再输出-->  
  44.   <property name="hibernate.format_sql">true</property>  
  45.   <!-- 罗列所有的映射文件  
  46.   <mapping resource="User.hbm.xml"/>  
  47.   <mapping resource="Area.hbm.xml"/>  
  48.  </session-factory>  
  49. </hibernate-configuration>  
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值