This is the code of that static static function. I am calling this function through jsp page.
public static SessionFactory getTemp(){
org.hibernate.SessionFactory sessionFactory=null;
try{
System.out.println("Before Createing session Factory successfully");
org.hibernate.cfg.Configuration Hiberconfig = new Configuration().addResource("player.hbm.xml");
System.out.println("Created the configuration successfully");
//Hiberconfig.addClass(com.player.class);
System.out.println("Added the player class to config");
Hiberconfig.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
System.out.println("Added the Dialect to config");
Hiberconfig.setProperty("hibernate.query.factory_class","org.hibernate.hql.classic.ClassicQueryTranslatorFactory");
Hiberconfig.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
System.out.println("Added the MySql Driver to config");
Hiberconfig.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/hiberdemo");
Hiberconfig.setProperty("hibernate.connection.username", "root");
Hiberconfig.setProperty("hibernate.connection.password", "");
System.out.println("Added the Database connection url to config");
//Fire up Hibernate
sessionFactory = Hiberconfig.buildSessionFactory();
System.out.println("Created session Factory successfully");
}
catch(Exception e){
System.out.println("\nProblem in getTemp()\n ");
}
return sessionFactory;
}
|