Hello,
I am new in hibernate, just in the learning phase.
I am using eclipse indigo, hibernate, oracle 10g.
In my first programme got from internet during run the programme the below error I am getting -
Code:
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 org.hibernate.cfg.Configuration.configure(Configuration.java:1411)
at com.chinmoy.hibernate.StoreData.main(StoreData.java:18)
Caused by: 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.doConfigure(Configuration.java:1481)
hibernate.cfg.xml:
Code:
<?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="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password"><password></property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@172.24.70.12:1521:<db name></property>
<property name="hibernate.connection.username"><user id></property>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<mapping resource="Employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Controller class (StoreData):
Code:
package com.chinmoy.hibernate;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class StoreData {
public static void main(String[] args) {
//creating configuration object
//Configuration cfg=new Configuration();
//cfg.configure("hibernate.cfg.xml");//populates the data of the configuration file
//creating seession factory object
//SessionFactory factory=cfg.buildSessionFactory();
SessionFactory factory=new Configuration().configure().buildSessionFactory();
//creating session object
Session session=factory.openSession();
//creating transaction object
//Transaction t=session.beginTransaction();
Employee e1=new Employee();
e1.setId(115);
e1.setFname("sonoo");
e1.setLname("jaiswal");
session.persist(e1);//persisting the object
//t.commit();//transaction is commited
session.close();
System.out.println("successfully saved");
}
}
I have add the below jar files -
antlr-2.7.6.jar
asm.jar
asm-attrs.jar
c3p0-0.9.1.jar
cglib-2.1.3.jar
commons-collections-2.1.1.jar
commons-logging-1.0.4.jar
dom4j-1.6.1.jar
ehcache-1.2.3.jar
ejb3-persistence.jar
hibernate3.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-validator.jar
jdbc2_0-stdext.jar
jta.jar
log4j-1.2.11.jar
xerces-2.6.2.jar
ojdbc14.jar
Please help me to run the program.
This is a very simple basic program.