日期:2014-05-17  浏览次数:20671 次

hibernate连接数据库,映射文件各种错误,求大神指导
<!--这是hibernate文件的配置-->
<?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">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>

    <session-factory>
        <property name="dialect">org.hibernate.dialect.OracleDialect</property>
        <property name="connection.url">jdbc:oracle:thin:@localhost:1521:ORCL</property>
        <property name="connection.username">accp</property>
        <property name="connection.password">sx</property>
        <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
     <property name="show_sql">true</property>
     <property name="current_session_context_class">thread</property>
     <mapping resource="com/entity/entity.hbm.xml"/>
    </session-factory>

</hibernate-configuration>

<!--这是映射文件-->
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-Mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
"http://hibernate.sourceforge.net/hibernate-Mapping-3.0.dtd">
<hibernate-Mapping package="com.entity">
<class name="Product" table="product">
<id name="id" type="java.lang.Integer">
<column name="id" sql-type="number" />
<generator class="sequence">
<param name="sequence">seq_id</param>
</generator>
</id>
<property name="productName" type="java.lang.String">
<column name="productname" sql-type="nvarchar2(30)" />
</property>
<property name="quantity" type="java.lang.Integer">
<column name="quantity" sql-type="number" />
</property>
</class>
</hibernate-Mapping>
<!--这是myeclipse上报的错误-->
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.addInputStream(Configuration.java:546)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:613)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1635)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1476)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)