位置:位于src目錄下
命名:hibernate.cfg.xml
案例:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<!-- DTD:用于擷取提示資訊 -->
<!-- hibernate的配置 -->
<hibernate-configuration>
<!-- 會話工廠 -->
<session-factory>
<!-- 配置資料庫連接配接的4個參數 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property><!-- 驅動 -->
<property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/shujuku</property><!--位址 -->
<property name="hibernate.connection.username"><u>zyf</u></property><!-- 使用者名 -->
<property name="hibernate.connection.password">123456</property><!-- 密碼 -->
<!-- 是否顯示sql語句 -->
<property name="show_sql">true</property>
<!-- 是否格式化sql語句 -->
<property name="format_sql">true</property>
<!-- 是否自動送出事務 -->
<property name="hibernate.connection.autocommit">true</property>
<!-- 配置JavaBean模型類與資料庫表的映射檔案 -->
<mapping resource="com/moli/hibernate/domain/User.hbm.xml" />
</session-factory>
</hibernate-configuration>