-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Resetting SessionFactory
PostPosted: Tue Apr 20, 2010 1:17 am 
Newbie

Joined: Tue Apr 20, 2010 1:13 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.