firends i m using netbeans ide and its placed hibernate.cfg.xml in default src/java folder
but whenever i run the application its displayed below error :
Initial SessionFactory creation failed.org.hibernate.HibernateException: /hibernate.cfg.xml not found
class :
public class myutil {
private static final SessionFactory sessionFactory = buildsf();
public static SessionFactory buildsf() {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
return new Configuration().configure("config/hibernate.cfg.xml").buildSessionFactory();
} catch (Throwable ex) { // Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
}
Use :
Check here usage. Or directly keep
hibernate.cfg.xmldirectly undersrc(not recommended).