【Hibernate学习笔记-4】在hibernate.cfg.xml中配置C3P0数据源

时间:2022-05-26 07:05:09
jar包

【Hibernate学习笔记-4】在hibernate.cfg.xml中配置C3P0数据源


hibernate.cfg.xml

【Hibernate学习笔记-4】在hibernate.cfg.xml中配置C3P0数据源
  1. <?xml version="1.0" encoding="GBK"?>
  2. <!DOCTYPE hibernate-configuration PUBLIC
  3. "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  4. "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  5. <hibernate-configuration>
  6. <session-factory>
  7. <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
  8. <property name="connection.url">jdbc:mysql://localhost:3306/sampledb</property>
  9. <property name="connection.username">root</property>
  10. <property name="connection.password">qaz</property>
  11. <property name="hibernate.c3p0.max_size">20</property>
  12. <property name="hibernate.c3p0.min_size">1</property>
  13. <property name="hibernate.c3p0.timeout">5000</property>
  14. <property name="hibernate.c3p0.max_statements">100</property>
  15. <property name="hibernate.c3p0.idle_test_period">3000</property>
  16. <property name="hibernate.c3p0.acquire_increment">2</property>
  17. <property name="hibernate.c3p0.validate">true</property>
  18. <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  19. <property name="hbm2ddl.auto">update</property><!--①-->
  20. <property name="show_sql">true</property>
  21. <property name="hibernate.format_sql">true</property>
  22. <mapping class="org.crazyit.app.domain.News"/>
  23. </session-factory>
  24. </hibernate-configuration>