hibernate的基本xml文件配置

需要导入基本的包hibernate下的bin下的required和同bin下optional里的c3p0包下的所有jar文件,当然要导入mysql的驱动包了。下面需要注意的是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>

    <!-- Database connection settings -->

    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>

    <property name="connection.url">jdbc:mysql://localhost:3306/news</property>

    <property name="connection.username">root</property>

     <property name="connection.password">123</property>

      <!--  C3p0数据源-->

     <property name="hibernate。c3p0.max_size">20</property>

     <property name="hibernate。c3p0.min_size">1</property>

    <property name="hibernate。c3p0.timeout">5000</property>

    <property name="hibernate。c3p0.max_statements">100</property>

     <property name="hibernate。c3p0.idle_test_period">3000</property>

     <property name="hibernate。c3p0.acquire_increment">2</property>

    <property name="hibernate。c3p0.validate">true</property>

     <!-- SQL dialect -->

    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

    <!-- Echo all executed SQL to stdout -->

     <property name="show_sql">true</property>

     <!-- Drop and re-create the database schema on startup -->

    <property name="hbm2ddl.auto">update</property>

      <!-- 将sql脚本进行格式输出 -->

    <property name="hibernate.format_sql">true</property>

    <!-- 罗列所有的持久化类的名字 -->

     <mapping class="com.news.News" />

  </session-factory>

</hibernate-configuration>

上一篇:Code Signal_练习题_Make Array Consecutive2


下一篇:virtualbox 创建com对象失败