天天看点

hibernate --MYSQL数据库 cfg.xml配置文件例子

<?xml version='1.0' encoding='utf-8'?>

 <!DOCTYPE hibernate-configuration PUBLIC

         "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

         <hibernate-configuration>

         <session-factory>

         <!--  配置使用的driver-->

         <!--  提交事务-->

         <property name="connection.autocommit">true</property>

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

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

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

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

         <!--  配置dialect方言,明确告诉hibernate 现在使用的是什么数据库-->

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

      <!-- 显示出对应的SQL语句-->

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

       <!--  指定管理的对象映射文件-->

         <mapping resource="com/jc/domain/Employee.hbm.xml"          />

         </session-factory>

         

         

         </hibernate-configuration>