-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to change database at runtime?
PostPosted: Sat May 12, 2007 3:06 am 
Beginner
Beginner

Joined: Sat May 12, 2007 2:55 am
Posts: 24
Hi friends,

As a part of an application , I am checking the username and password for a particular user in cenral database, i am using this database configuration in hibernate.cfg.xml file.
once the user is authenticated all his further data is stored in his seperate database (not tables) whose database name is stored in central database along with his username and password. now the problem is how can i switch over to new database from central database. for all my users, i have a seperate database and this has to be dynamic binding.
i am using a struts-hibernate 3.1 combination with mysql5.0.

i think i need a seperate SessionFactory but not have clear idea. any help will help me a lot!


thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 12, 2007 1:25 pm 
Beginner
Beginner

Joined: Mon Nov 06, 2006 2:40 am
Posts: 29
Location: New Delhi, India
use progarmatic configuration of session factory

Code:
Configuration cfg = new Configuration()
    .addClass(org.hibernate.auction.Item.class)
    .addClass(org.hibernate.auction.Bid.class)
    .setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect")
    .setProperty("hibernate.connection.datasource", "java:comp/env/jdbc/test")


or refer to following link...
http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configuration.html


-- Don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 12:16 am 
Beginner
Beginner

Joined: Sat May 12, 2007 2:55 am
Posts: 24
thanks
Sagi wrote:
use progarmatic configuration of session factory

Code:
Configuration cfg = new Configuration()
    .addClass(org.hibernate.auction.Item.class)
    .addClass(org.hibernate.auction.Bid.class)
    .setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect")
    .setProperty("hibernate.connection.datasource", "java:comp/env/jdbc/test")


or refer to following link...
http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configuration.html


-- Don't forget to rate :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 12:50 am 
Beginner
Beginner

Joined: Mon Nov 06, 2006 2:40 am
Posts: 29
Location: New Delhi, India
Please rate if it helped.... :)


Top
 Profile  
 
 Post subject: What about the chache, does it cache by connection/database?
PostPosted: Mon May 14, 2007 11:26 am 
Newbie

Joined: Mon May 14, 2007 11:23 am
Posts: 2
Does Hibernate cache by connection/database when we change the database programatically, or it will rather use the same ?


Top
 Profile  
 
 Post subject: What about the chache, does it cache by connection/database?
PostPosted: Mon May 14, 2007 11:29 am 
Newbie

Joined: Mon May 14, 2007 11:23 am
Posts: 2
Does Hibernate cache by connection/database when we change the database programatically, or it will rather use the same ?


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

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.