I am having problem with the execution of the Hibernate program . I am new to Hibernate.. Here is the error trace .. i received while executing the program
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 store_h1.main(store_h1.java:15)
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:1481)
... 2 more
here is in hibernate configuration file 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="hbm2ddl.auto">update</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1522:xe</property>
<property name="connection.username">swapnil</property>
<property name="connection.password">swapnil</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="show_sql">true</property>
<mapping resource="h1.hbm.xml"/>
</session-factory>
</hibernate-configuration>
and here is the main class
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.*;
public class store_h1 {
public static void main(String[] args) {
//create configuration object
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
//create session factory object
SessionFactory factory = cfg.buildSessionFactory();
//create session object
Session session= factory.openSession();
//create Transaction object
Transaction t = session.beginTransaction();
h1 h = new h1();
h.set_id(30);
h.set_first("something");
h.set_last("Hibernate");
session.persist(h);
t.commit();
session.close();
System.out.println("Sucessfully Hibernate used for storing data ");
}
}
and finally the mapping file
<?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>
<class name = "h1" table="t1">
<--<id name="empid"></id>-->
<property name="empid"></property>
<property name="first_name"></property>
<property name="last_name"></property>
</class>
</hibernate-mapping>
PLease can you point out the mistake i am doing here .... i am using eclipse to run the program and have also included the jar file from hibernate/lib/required and also included the jar file for jdbc from oracle and i am also connected to the internet. What i am missing here ..... ?
