java - 线程中的异常 "main"org.hibernate.HibernateException : Could not parse configuration: hibernate. cfg.xml

标签 java hibernate

我遇到以下异常:

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 com.ClientForSave.main(ClientForSave.java:26)
    Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
        at org.dom4j.io.SAXReader.read(SAXReader.java:484)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)
        ... 2 more

整个堆栈跟踪

这是我的配置文件:

<hibernate-configuration> 
    <session-factory> 
       <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> 
       <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:devt2x</property>
       <property name="hibernate.connection.username">scott</property> 
       <property name="hibernate.connection.password">tiger</property> 
       <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
       <property name="show_sql">true</property> 
    </session-factory>
</hibernate-configuration>

最佳答案

我能够解决我的问题。问题是 dtd 和所需的 jar 不匹配。 我转到 dtd 中的 url 并下载了 jar,它现在可以工作了 我的 hibernate.cfg.xml 文件中的 dtd

关于java - 线程中的异常 "main"org.hibernate.HibernateException : Could not parse configuration: hibernate. cfg.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27358037/

相关文章:

java - "java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy"哪个 jar 不见了

java - 如何将 Hibernate 从 jboss-logging 切换到 logback?

java - 添加 TextChangedListener 时应用崩溃

java - Class<T>.isAssignableFrom(Class<?> cls) 的建议替代方案是什么?

java - SAX 解析器由于 <br/> 标记而忽略文本

hibernate - 通过 Hibernate 的 PostgreSql 数据库备份作为 Web 应用程序中的持久层

java - 如何使用 Selenium WebDriver 从隐藏范围中检索文本?

java - 创建新字符串作为文字/新对象时的内存分配

java - 没有配置文件的 Hibernate 配置

sql - JPA @ElementCollection 生成奇怪的唯一键