gpt4 book ai didi

java - org.hibernate.HibernateException : Could not parse configuration: hibernate. cfg.xml

转载 作者:行者123 更新时间:2023-11-29 05:41:10 29 4
gpt4 key购买 nike

请帮我解决这个错误。

org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1494)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.jbpm.db.hibernate.HibernateHelper.createConfiguration (HibernateHelper.java:89)
at org.jbpm.persistence.db.DbPersistenceServiceFactory.getConfiguration (DbPersistenceServiceFactory.java:75)
at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:104)
at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:93)
at org.jbpm.persistence.jta.JtaDbPersistenceService.getTransactionManager(JtaDbPersistenceService.java:100)
at org.jbpm.persistence.jta.JtaDbPersistenceService.getTransactionStatus(JtaDbPersistenceService.java:88)
at org.jbpm.persistence.jta.JtaDbPersistenceService.<init>(JtaDbPersistenceService.java:50)
at org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory.openService(JtaDbPersistenceServiceFactory.java:61)
at org.jbpm.svc.Services.getService(Services.java:160)
at org.jbpm.svc.Services.getPersistenceService(Services.java:197)
at org.jbpm.JbpmContext.getPersistenceService(JbpmContext.java:695)
at org.jbpm.JbpmContext.getJobSession(JbpmContext.java:639)
at org.jbpm.job.executor.LockMonitorThread.unlockOverdueJobs(LockMonitorThread.java:64)
at org.jbpm.job.executor.LockMonitorThread.run(LockMonitorThread.java:43)
Caused by: org.dom4j.DocumentException: Connection reset Nested exception: Connection reset
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484)
... 15 more

我是 hibernate 新手,很难理解错误是什么。 hibernate使用的jar文件如下

hibernate-annotations.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate3.jar

我的 hibernate.cfg.xml 文件是这样的

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration SYSTEM
"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/datacenter</property>
<property name="connection.username">root</property>
<property name="connection.password">admin</property>
<!-- <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

-->

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="current_session_context_class">thread</property>
<property name="show_MySql">TRUE</property>
<property name="format_sql">TRUE</property>
<!-- <property name="jboss.as.jpa.providerModule">hibernate3- bundled</property> -->


<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<!-- <property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTransla torFactory</property> -->

<!-- List of annotated classes-->
<!-- Associations -->
<!-- One to one -->
<!-- <mapping class="Emp_Timecard" />
<mapping class="maindoor" /> -->
<mapping class="model.serverroom" />
<mapping class="model.resourcelist" />
<mapping class="model.timesheet" />
<mapping class="model.maindoor" />
<!-- <mapping class="timesheet" />
<mapping class="Resource_list"/> -->


</session-factory>
</hibernate-configuration>

最佳答案

我认为您在正确连接到数据库时遇到了问题。您确定用户名和密码正确吗?还是您已经有一个名为 datacenter 的数据库?

也尝试将文档类型更改为

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

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

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com