I am new to Hibernate. I create a simple program to insert values to db using Hibernate.
My File structure looks like
src -> com.visolve -> AddStudent.java and student.java
src -> com.xml -> hibernate.cfg.xml and student.hbm.xml
I use the following code to communicate the confiure file from AddStudent.java
String file = "/src/com/xml/hibernate.cfg.xml";
sessionFactory = new Configuration().configure(new File(file)).buildSessionFactory();
My hibernate.cfg.xml file is
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/
hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost:3306/hibernateExamples</property>
<property name="hibernate.connection.username">
root</property>
<property name="hibernate.connection.password">
</property>
<property name="hibernate.connection.pool_size">
10</property>
<property name="show_sql">true</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto">
update</property>
<!-- Mapping files -->
<mapping resource="com/xml/student.hbm.xml"/>
</session-factory>
</hibernate-configuration>
If i check new File(file).exists() means it returns true.. But here it returns the following exception
Initial SessionFactory creation failed.org.hibernate.HibernateException: Could not parse configuration: src/com/xml/hibernate.cfg.xml
Exception in thread "main" java.lang.NullPointerException
at com.visolve.AddStudent.main(AddStudent.java:44)
"http://hibernate.sourceforge.net/andhibernate-configuration-3.0.dtd">?