Oracle休眠cfg

时间:2013-02-11 18:59:28

标签: java oracle hibernate

尝试启动休眠时出现此错误。我是一个休眠的新手,所以希望有人可以指出我用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;必须为元素类型“property”声明属性“value”。     at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)     at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(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.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(Unknown 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(Unknown Source)     在com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(未知来源)     at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)     at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl $ JAXPSAXParser.parse(Unknown Source)     在org.dom4j.io.SAXReader.read(SAXReader.java:465)     在org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2238)     ......还有11个

2 个答案:

答案 0 :(得分:0)

更改:connection.driver_class

官方: hibernate.connection.driver_class

还请阅读此article

答案 1 :(得分:0)

尝试使用 <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>

作为一个新手,你可以阅读整个hibernate文档 http://www.hibernate.org/docs