这里有一个新手!!!我的疑问是关于HIBERNATE编程,我收到这个错误,即使经过这么多的研究,我也无法解决!第一次当我执行程序时它已成功处理并且值被插入数据库中,但突然间我得到了这个错误,从那时起就无法继续前进! PS:当我尝试在我的朋友计算机上运行相同的程序时,它可以工作:/
以下是CONSOLE中的错误:
Exception in thread "main" org.hibernate.Hiberna`enter code here`teException: 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.snycon.hibernateEx.EmployeeAction.main(EmployeeAction.java:13)
引起:org.dom4j.DocumentException:来自服务器的文件意外结束嵌套异常:来自服务器的文件意外结束
在org.dom4j.io.SAXReader.read(SAXReader.java:484)
在org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)
... 2更多c
下面是我的hibernate.cfg.xml文件:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/jdbcex</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
答案 0 :(得分:1)
将hibernate.cfg.xml
的架构声明更改为:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">