<!--標準的XML文件的起始行,version='1.0'表明XML的版本,encoding='gb2312'表明XML文件的編碼方式-->
<?xml version='1.0' encoding='gb2312'?>
<!--表明解析本XML文件的DTD文檔位置,DTD是Document Type Definition 的縮寫,即文檔類型的定義,XML解析器使用DTD文檔來檢查XML文件的合法性。hibernate.sourceforge.net/hibernate-configuration-3.0dtd可以在Hibernate3.1.3軟件包中的src\org\hibernate目錄中找到此文件-->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!--聲明Hibernate配置文件的開始-->
<hibernate-configuration>
<!--表明以下的配置是針對session-factory配置的,SessionFactory是Hibernate中的一個類,這個類主要負責保存HIbernate的配置信息,以及對Session的操作-->
<session-factory>
<!--配置數據庫的驅動程序,Hibernate在連接數據庫時,需要用到數據庫的驅動程序-->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!--設置數據庫的連接url:jdbc:mysql://localhost/hibernate,其中localhost表示mysql服務器名稱,此處為本機, hibernate是數據庫名-->
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate</hibernate>
<!--連接數據庫是用戶名-->
<property name="hibernate.connection.username">root</property>
<!--連接數據庫是密碼-->
<property name="hibernate.connection.password">123456</property>
<!--數據庫連接池的大小-->
<property name="hibernate.connection.pool.size">20</property>
<!--是否在后臺顯示Hibernate用到的SQL語句,開發時設置為true,便于差錯,程序運行時可以在Eclipse的控制臺顯示Hibernate的執行Sql語句。項目部署后可以設置為false,提高運行效率-->
<property name="hibernate.show_sql">true</property>
<!--jdbc.fetch_size是指Hibernate每次從數據庫中取出并放到JDBC的Statement中的記錄條數。Fetch Size設的越大,讀數據庫的次數越少,速度越快,Fetch Size越小,讀數據庫的次數越多,速度越慢-->
<property name="jdbc.fetch_size">50</property>
<!--jdbc.batch_size是指Hibernate批量插入,刪除和更新時每次操作的記錄數。Batch Size越大,批量操作的向數據庫發送Sql的次數越少,速度就越快,同樣耗用內存就越大-->
<property name="jdbc.batch_size">23</property>
<!--jdbc.use_scrollable_resultset是否允許Hibernate用JDBC的可滾動的結果集。對分頁的結果集。對分頁時的設置非常有幫助-->
<property name="jdbc.use_scrollable_resultset">false</property>
<!--connection.useUnicode連接數據庫時是否使用Unicode編碼-->
<property name="Connection.useUnicode">true</property>
<!--connection.characterEncoding連接數據庫時數據的傳輸字符集編碼方式,最好設置為gbk,用gb2312有的字符不全-->
<property name="connection.characterEncoding">gbk</property>
<!--hibernate.dialect 只是Hibernate使用的數據庫方言,就是要用Hibernate連接那種類型的數據庫服務器。-->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!--指定映射文件為“hibernate/ch1/UserInfo.hbm.xml”-->
<mapping resource="org/mxg/UserInfo.hbm.xml">
</session-factory>
</hibernate-configuration>
有什么補充的希望大家幫忙補充!
<?xml version='1.0' encoding='gb2312'?>
<!--表明解析本XML文件的DTD文檔位置,DTD是Document Type Definition 的縮寫,即文檔類型的定義,XML解析器使用DTD文檔來檢查XML文件的合法性。hibernate.sourceforge.net/hibernate-configuration-3.0dtd可以在Hibernate3.1.3軟件包中的src\org\hibernate目錄中找到此文件-->
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!--聲明Hibernate配置文件的開始-->
<hibernate-configuration>
<!--表明以下的配置是針對session-factory配置的,SessionFactory是Hibernate中的一個類,這個類主要負責保存HIbernate的配置信息,以及對Session的操作-->
<session-factory>
<!--配置數據庫的驅動程序,Hibernate在連接數據庫時,需要用到數據庫的驅動程序-->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!--設置數據庫的連接url:jdbc:mysql://localhost/hibernate,其中localhost表示mysql服務器名稱,此處為本機, hibernate是數據庫名-->
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate</hibernate>
<!--連接數據庫是用戶名-->
<property name="hibernate.connection.username">root</property>
<!--連接數據庫是密碼-->
<property name="hibernate.connection.password">123456</property>
<!--數據庫連接池的大小-->
<property name="hibernate.connection.pool.size">20</property>
<!--是否在后臺顯示Hibernate用到的SQL語句,開發時設置為true,便于差錯,程序運行時可以在Eclipse的控制臺顯示Hibernate的執行Sql語句。項目部署后可以設置為false,提高運行效率-->
<property name="hibernate.show_sql">true</property>
<!--jdbc.fetch_size是指Hibernate每次從數據庫中取出并放到JDBC的Statement中的記錄條數。Fetch Size設的越大,讀數據庫的次數越少,速度越快,Fetch Size越小,讀數據庫的次數越多,速度越慢-->
<property name="jdbc.fetch_size">50</property>
<!--jdbc.batch_size是指Hibernate批量插入,刪除和更新時每次操作的記錄數。Batch Size越大,批量操作的向數據庫發送Sql的次數越少,速度就越快,同樣耗用內存就越大-->
<property name="jdbc.batch_size">23</property>
<!--jdbc.use_scrollable_resultset是否允許Hibernate用JDBC的可滾動的結果集。對分頁的結果集。對分頁時的設置非常有幫助-->
<property name="jdbc.use_scrollable_resultset">false</property>
<!--connection.useUnicode連接數據庫時是否使用Unicode編碼-->
<property name="Connection.useUnicode">true</property>
<!--connection.characterEncoding連接數據庫時數據的傳輸字符集編碼方式,最好設置為gbk,用gb2312有的字符不全-->
<property name="connection.characterEncoding">gbk</property>
<!--hibernate.dialect 只是Hibernate使用的數據庫方言,就是要用Hibernate連接那種類型的數據庫服務器。-->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!--指定映射文件為“hibernate/ch1/UserInfo.hbm.xml”-->
<mapping resource="org/mxg/UserInfo.hbm.xml">
</session-factory>
</hibernate-configuration>
有什么補充的希望大家幫忙補充!