Beginner |
|
Joined: Tue Feb 07, 2006 10:39 pm Posts: 46
|
this is my test file of the hibernate:
package test;
import hibernate.ThreadLocalSession; import model.User;
import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration;
public class firstName {
/* * Hibernate example to inset data into Contact table */ public static void main(String[] args) { Session ses = null;
try{ ses = ThreadLocalSession.currentSession(); //Create new instance of User and set values in it by reading them from form object System.out.println("Inserting Record"); User user = new User(); user.setEmpNo("002"); user.setFirstName("Hii"); user.setLastName("Ling"); user.setDesignation("null"); user.setCompany("xyz"); user.setDepartment("abc"); user.setExtNo("375"); ses.save(user); System.out.println("Done"); }catch(Exception e){ System.out.println(e.getMessage()); }finally{ // Actual user insertion will happen at this step ses.flush(); ses.close();
} } }
the error shows when i run the java application is as shown below:
** 2 javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial java.lang.NullPointerException at test.firstName.main(firstName.java:36) Exception in thread "main"
can anyone comment on this??
|
|