---
title: "在hibernate框架中配置显示sql语句"
author: "ch0431"
date: "2010-10-15T16:34:45Z"
tags: []
categories: ["企业架构"]
slug: "hibernate-sql"
draft: false
lastmod: "2010-10-15T16:34:45Z"
id: 785917
url: "https://ch0431.iteye.com/blog/785917"
---

&lt;hibernate-configuration&gt;

   &lt;session-factory&gt;

  &lt;property name="myeclipse.connection.profile"&gt;mysql&lt;/property&gt;  
  &lt;mapping resource="com/chenhui/bean/TUserLogin.hbm.xml" /&gt;  
  &lt;mapping resource="com/chenhui/bean/TUserContent.hbm.xml" /&gt;  
  &lt;mapping resource="com/chenhui/bean/TComment.hbm.xml" /&gt;  
  &lt;mapping resource="com/chenhui/bean/TVideo.hbm.xml" /&gt;

      &lt;property name="dialect"&gt;  
          org.hibernate.dialect.MySQLDialect  
      &lt;/property&gt;

   &lt;property name="connection.url"&gt;  
       jdbc:mysql://localhost:3306/video  
    &lt;/property&gt;

  &lt;property name="connection.username"&gt;root&lt;/property&gt;

  &lt;property name="connection.password"&gt;123&lt;/property&gt;

  &lt;property name="connection.driver\_class"&gt;  
   com.mysql.jdbc.Driver  
  &lt;/property&gt;  
    
  &lt;property name="hibernate.show\_sql"&gt;true&lt;/property&gt;&lt;!-- 配置显示sql语句 --&gt;  
  &lt;property name="format\_sql"&gt;true&lt;/property&gt;&lt;!-- 让输出的sql语句格式化 --&gt;

 &lt;/session-factory&gt;

&lt;/hibernate-configuration&gt;