2015-10-06 65 views
0

同時使用Oracle 10g冬眠第一應用

ERROR:- 
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). 
log4j:WARN Please initialize the log4j system properly. 
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml 
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1491) 
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1425) 
    at hibernate.StoreData.main(StoreData.java:13) 
Caused by: org.dom4j.DocumentException: Error on line 1 of document : The processing instruction target matching "[xX][mM][lL]" is not allowed. Nested exception: The processing instruction target matching "[xX][mM][lL]" is not allowed. 
    at org.dom4j.io.SAXReader.read(SAXReader.java:482) 
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481) 
    ... 2 more 

映射文件創建簡單的Hibernate應用程序我得到錯誤: -

<?xml version='1.0' encoding='UTF-8'?> 
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 

<hibernate-mapping> 
    <class name="hibernate.Employee" table="emp1000"> 
    <id name="id"> 
    <generator class="assigned"></generator> 
    </id> 

    <property name="firstName"></property> 
    <property name="lastName"></property> 

    </class> 

</hibernate-mapping> 

配置文件: -

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

<hibernate-configuration> 

    <session-factory> 
     <property name="hbm2ddl.auto">update</property> 
     <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property> 
     <property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property> 
     <property name="connection.username">hr</property> 
     <property name="connection.password">hr</property> 
     <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> 

    <mapping resource="employee.hbm.xml"/> 
    </session-factory> 

</hibernate-configuration> 

回答