2013-02-11 119 views
0

我試圖啓動我的休眠時出現此錯誤。我是一個hibernate新手,所以希望有人能指出我用我的cfg犯的錯誤。我列出了錯誤,希望這是一個簡單的解決方法,謝謝。Oracle休眠cfg

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

<!-- Database connection settings --> 
    <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> 
    <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl"</property> 
    <property name="connection.username">scott</property> 
    <property name="connection.password">tiger</property> 
    <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/> 
    <!-- Echo all executed SQL to stdout --> 
    <property name="show_sql">true</property> 
</session-factory> 

Exception in thread "main" org.hibernate.MappingException: invalid configuration 
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2241) 
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:230) 
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:71) 
at org.hibernate.cfg.Configuration.configure(Configuration.java:2158) 
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:212) 
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:71) 
at org.hibernate.cfg.Configuration.configure(Configuration.java:2137) 
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:206) 
at HibernateContext.setConfiguration(HibernateContext.java:20) 
at HibernateContext.addClass(HibernateContext.java:205) 
at HibernateContext.addClasses(HibernateContext.java:216) 
at main.main(main.java:8) 

所致:org.xml.sax.SAXParseException; lineNumber:14; columnNumber:89;必須爲元素類型「屬性」聲明屬性「值」。 在com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(來源不明) 在com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(來源不明) 在COM。 sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org。 apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source) at com.sun.org.apache。 xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(U nknown Source) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl $ FragmentContentDriver.next(Unknown Source ) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source) at com .sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org .apache.xerces.internal.parsers.XML11Configuration.parse(未知來源) at com.sun.org.apache.xerces.internal.parsers.XMLP arser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl $ JAXPSAXParser。解析(來源不明) 在org.dom4j.io.SAXReader.read(SAXReader.java:465) 在org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2238) ...... 11多個

+0

博學多聞整個Hibernate文檔,它會告訴你的行號錯誤所在。這是您的XMl語法錯誤,可能與hibernate本身沒有任何特定關係。如果您顯示的列表確實是整個xml文件,那麼您缺少一個標記。 – OldProgrammer 2013-02-11 19:03:37

回答

0

變化:connection.driver_class

官方: hibernate.connection.driver_class

也看過這article使用 <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>

作爲一個新手

+0

這改變了我的錯誤是找不到JDBC驅動程序。但是,使用oracle驅動程序,它會給我無法連接的錯誤。 – neuroh 2013-02-11 22:25:29

+0

我不認爲你的[[如果你沒有改變爲hibernate.connection.driver_class,工作將會很清晰。 – 2013-02-12 05:28:07