java hibernate unable to read xml_java-异常:无法解析配置:hibernate.cfg.xml

实际上,我正在尝试进行休眠日志记录.这是我的hibernate.cfg.xml文件

/p>

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

update

org.hibernate.dialect.MySQLDialect

jdbc:mysql://localhost:3306/temp

root

root

com.mysql.jdbc.Driver

这是例外…

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).

log4j:WARN Please initialize the log4j system properly.

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.subhas.mypackage.StoreData.main(StoreData.java:13)

Caused by: org.dom4j.DocumentException: Connection refused: connect Nested exception: Connection refused: connect

at org.dom4j.io.SAXReader.read(SAXReader.java:484)

at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)

... 2 more

这是employee.hbm.xml

/p>

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

这是我的主班

public class StoreData {

public static void main(String[] args) {

//creating configuration object

Configuration cfg=new Configuration();

cfg.configure("hibernate.cfg.xml");

//creating session factory object

SessionFactory factory=cfg.buildSessionFactory();

//creating session object

Session session=factory.openSession();

//creating transaction object

Transaction transaction=session.beginTransaction();

Employee employee=new Employee();

employee.setId(5000);

employee.setfName("Subhas");

employee.setlName("Gupta");

//persisting the object

session.persist(employee);

//commit the transaction object

transaction.commit();

session.close();

System.out.println("Data Saved Successfully");

}

}

我无法为此找到完美的解决方案.有人可以帮我吗?谢谢.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值