我遇到以下异常:
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/