java中hibernate的相关配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!--指定链接数据库所用的驱动-->
<property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<!--指定链接数据库的url,其中sundays是本应用链接的数据库名-->
<property name="hibernate.connection.url">jdbc:mysql://localhost/sundays?useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false&amp;serverTimezone=GMT</property>
<!--指定链接数据库的用户名-->
<property name="hibernate.connection.username">root</property>
<!--指定链接数据库的密码-->
<property name="hibernate.connection.password">123456</property>
<!--指定连接池里最大链接数-->
<property name="hibernate.c3p0.max_size">10</property>
<!--指定链接池最小链接数-->
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!--指定连接池里链接的超时时长-->
<property name="hibernate.c3p0.timeout"></property>
<!--指定连接池里最大缓存多少个Statement对象-->
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.c3p0.validate">ture</property>
<!--持久化类名-->
<mapping resource="com/sunday/hibernate/helloworld/News.hbm.xml"/>
</session-factory>
</hibernate-configuration>

 

原文地址:https://www.cnblogs.com/sundaysjava/p/10325731.html