Hi!!
I'm new with hibernate. I'm trying to make an example with mysql and hibernate using JBuiderX
I defined a class Singleton with the following code
public class Singleton {
private SessionFactory sessionFactory;
public Singleton() {
try {
System.out.println("Initializing Hibernate");
sessionFactory = new Configuration().configure().buildSessionFactory();
System.out.println("Finished Initializing Hibernate");
} catch (HibernateException e) {
e.printStackTrace();
}
}
public static void main(
String[] args) {
Singleton instance = new Singleton();
System.exit(0);
}
}
as the hibernate documentation say. But when I run the Singleton to see if I can connect, I obtain the following error
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
net.sf.hibernate.HibernateException: /hibernate.cfg.xml not found
at net.sf.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:872)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:896)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:883)
at com.tutorial.hibernate.db.Singleton.<init>(Singleton.java:23)
at com.tutorial.hibernate.db.Singleton.main(Singleton.java:31)
The hibernate.cfg.xml is in the src directory
Anybody can help me!!!
REgards
Naty