hibernate 的 org.dom4j.DocumentException: Connection timed out 问题

来源:互联网 发布:matlab生成随机矩阵 编辑:程序博客网 时间:2024/05/14 08:15


hibbernate的异常的一种情况


一开始以为是数据库连接问题。。。。错了

Communication failure during handshake. Is there a server running on localhost:3306?这个才是数据库连接问题

---特别要注意版本对应,这种问就出现在下面了

问题定位:

org.dom4j.DocumentException: Connection timed out

Connection timed out: connect Nested exception: Connection timed out: connect

出现这个异常的原因之一是读取配置文件超时。


通常是在读取hibernate配置文件验证dtd时版本不对造成的。所以在生成hibernate配置文件的时候要注意配置文件的dtd版本。根据相应的hibernate.jar版本,生成对应的hbm.cfg.xml

如果出现以上异常 可以试下

<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

转换试下

<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

又或者是反过来!

0 0