1

我是 Hibernate 的新手....我尝试了这段代码,但我得到了Could not parse configuration: NewFile.cfg.xml(.cfg.xml 文件的名称)

<?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>
    <!-- connection to oracle -->
    <propertyname="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver </property>
    <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE
</property>                 
    <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
    <property name="hibernate.connection.username">system</property>
    <property name="hibernate.connection.password">system</property>

    <!-- autocommit -->
    <property name="hibernate.connection.autocommit">false</property>

    <!-- to display sql query generated while running program  -->
    <property name="show_sql">true</property>
    <property name="format_sql">true</property>
    <property name="use_sql_comments">true</property>

    <!-- for jdbc transaction -->
    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.
JDBCTransactionFactory</property>

    <!-- mapping file -->
    <mapping resource="Mapping.hbm.xml"/>       
  </session-factory>
4

2 回答 2

1

<hibernate-configuration>缺少结束标记:

</hibernate-configuration>
于 2013-10-21T13:07:15.523 回答
0
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver </property>

您的开始标签与结束标签不匹配。

于 2014-03-05T07:49:50.113 回答