Hi
use this code in your Application to initialize new sessionfactory by user given parameters. remove cfg.xml
Code:
Configuration confg = new Configuration();
confg.setProperty("hibernate.connection.driver_class","net.sourceforge.jtds.jdbc.Driver");
confg.setProperty("hibernate.connection.url","jdbc:jtds:sqlserver://"+servername+":" +hibernateConfig.getPort() +"/" + dbname);
confg.setProperty("hibernate.connection.username",username);
confg.setProperty("hibernate.connection.password",password);
confg.setProperty("hibernate.dialect","org.hibernate.dialect.SQLServerDialect");
confg.setProperty("hibernate.connection.pool_size",""+poolsize);
//confg.setProperty("hibernate.cache.provider_class","org.hibernate.cache.NoCacheProvider");
confg.setProperty("hibernate.cache.provider_class","org.hibernate.cache.OSCacheProvider");
confg.setProperty("hibernate.current_session_context_class","thread");
confg.setProperty("hibernate.jdbc.use_scrollable_resultset","true");
confg.setProperty("hibernate.show_sql","true");
try{
confg.addClass(Class2.class);
confg.addClass(Class2.class);
sessionFactory = confg.buildSessionFactory();
} catch (MappingException e) {
throw e;
} catch (HibernateException e) {
throw e;
}
Amila
(Don't forget to rate if helps)