i am trying to connect test a normal insertion code into mysql database using hibernate and getting error for this, i write the exception details below.
log4j:WARN No appenders could be found for logger (org.jboss.logging). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" org.hibernate.internal.util.config.ConfigurationException: Could not locate cfg.xml resource [/home/controller/Documents/sts_work/webtracker/src/main/java/hibernate.cfg.xml] at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:53) at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:163) at org.hibernate.cfg.Configuration.configure(Configuration.java:258) at testHBConnection.main(testHBConnection.java:12) and my java file for test is
import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import com.ar.entity.Student; public class testHBConnection { public static void main(String[] args) { // TODO Auto-generated method stub SessionFactory sf=new Configuration().configure("/home/controller/Documents/sts_work/webtracker/src/main/java/hibernate.cfg.xml") .addAnnotatedClass(Student.class) .buildSessionFactory(); Session ses=sf.getCurrentSession(); try { Student stu= new Student("","name"); ses.beginTransaction(); ses.save(stu); ses.getTransaction().commit(); } catch(Exception e) { System.out.println("Exception "+e); } finally{ } } } and i linked here my project structure below
where Student is the pojo file releted to database table how can i solve this problem?