Originally posted by Gajanan Bandale:
Hi I already Import the required but not any effect.
I made some changes in my code as follows then also i find one error :
import java.util.*;
import org.hibernate.*;
import org.hibernate.cfg.Configuration;
//import javax.security.auth.login.Configuration;
public class MyUsersTest
{
public static final String Object = null;
public static void main(String[]args) throws Exception
{
Configuration config = new Configuration();
SessionFactory sessions = config.buildSessionFactory();
config.addClass(MyUsers.class);
Session session = session.openSession(null);
//Object config;
//((Object)config).addClass(MyUsers.class);
//((Object)config).getClass();
//Class SessionFactory = ((Object)config).getClass();
//Session session = SessionFactory.openSession();
try{
MyUsers newUser = new MyUsers();
newUser.setID("Wipro");
newUser.setUserName("Wipro Technolgoeis");
newUser.setPassword("wipro");
newUser.setEmailAddress("wipro@tech.com");
newUser.setLastLogin(new Date());
session.save(newUser);
}
finally
{
session.flush();
session.close();
}
Object object2 = SessionFactory.close();
}
}
Then i am getting error :
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Cannot make a static reference to the non-static method close() from the type SessionFactory
Type mismatch: cannot convert from void to Object
at MyUsersTest.main(MyUsersTest.java:39)