Hey guys, total newbie to hibernate, but loving it so far. Basically I have a scenario in which the database may be changed, and would like to give users the ability to change the database connection settings (username, url, and password). The problem I'm having is that when those are changed, the session factory still believes it is connected to the old database. I get the impression that something else needs to be modified that I am unaware of. Here is my code:
Code:
private static boolean buildSessionFactory() {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
// config file.
sessionFactory.close();
sessionFactory = null;
AnnotationConfiguration t = new AnnotationConfiguration().configure();
t.setProperty("hibernate.connection.username", databaseUserName);
t.setProperty("hibernate.connection.url", databaseURL);
t.setProperty("hibernate.connection.password", databasePassword);
sessionFactory = t.buildSessionFactory();
return true;
} catch (Throwable ex) {
System.out.println("here");
return false;
}
}
Thanks a ton
Erock