Hi, I am new 2 Hibernate, I am using Hibernate 3.0.5. I have made a small application but i;m not able to run it....
Details are as follow...
Source Code Structure...
+src
+com.ibm.myhibernate.config
hibernate.cfg.xml
+com.ibm.myhibernate.hbm
BwAnobagActivity.hbm.xml
+ com.ibm.myhibernate.impl
BwAnobagActivity.java
Myhibernate.java
hibernate.cfg.xml
<?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="dialect">
org.hibernate.dialect.DB2Dialect
</property>
<property name="hibernate.connection.driver_class">
com.ibm.db2.jcc.DB2Driver
</property>
<property name="hibernate.connection.url">
jdbc:db2://9.182.249.18:50000/VISTADB
</property>
<property name="hibernate.connection.username">dbuser</property>
<property name="hibernate.connection.password">
welcome2ibm
</property>
<property name="show_sql">true</property>
<!-- Mapping files -->
<mapping
resource="com/ibm/myhibernate/hbm/BwAnobagActivityDE.hbm.xml" />
</session-factory>
</hibernate-configuration>
Myhibernate.java
package com.ibm.myhibernate.impl;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class Myhibernate {
public static void main(String[] args) {
Session session = null;
try{
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.configure("com/ibm/myhibernate/config/hibernate.cfg.xml").buildSessionFactory();
session = sessionFactory.openSession();
System.out.println("Inserting Record");
BwAnobagActivityDE bwAnobagActivityDE = new BwAnobagActivityDE();
bwAnobagActivityDE.setCanobagPlaceOfWork("India");
bwAnobagActivityDE.setTbwAnobagDataId(new Long(1256336));
session.save(bwAnobagActivityDE);
System.out.println("Done");
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
session.flush();
session.close();
}
}
}
When i am trying to run Myhibernate.java
It's giving me exception
INFO: hibernate.properties not found
Jan 5, 2008 7:10:07 PM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jan 5, 2008 7:10:07 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Jan 5, 2008 7:10:08 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: com/ibm/myhibernate/config/hibernate.cfg.xml
Jan 5, 2008 7:10:08 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: com/ibm/myhibernate/config/hibernate.cfg.xml
Exception in thread "main" java.lang.NullPointerException
at com.ibm.myhibernate.impl.Myhibernate.main(Myhibernate.java:62)
|