-->
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.  [ 4 posts ] 
Author Message
 Post subject: i am using more than one database in my app...please help me
PostPosted: Sat Nov 17, 2007 5:12 am 
Newbie

Joined: Fri Nov 16, 2007 3:05 pm
Posts: 14
Hi Guys,

I am working on a application , where, when ever i create a CASE, I have to create a seperate database for that case in the backend.
I dynamically create database through the application for each and every CASE that is created. For example if i have created 10 cases through my application , it means i would have created ten databases in the backend.

I like to use hibernate in my application. I like to know whether is that possible for me to get connection to the database , based on the CASE that i am selecting from the CASE LIST. For example , if i select CASE1 from the case list , then i should get connection to the CASE1 database.

(Actually i went through the reference document , i hope i can achieve it by programatically using configure.setproperty("hibernate.connection.url","jdbc:mysql://gsche56:3306/CASE1" ) before creating the sessionfactory. The CASE1 here is the database of the selected case.

Is there anyother way to do this.Can some one please help me on this.

NOTE: I like to use connection pooling in my app for better performance.

thanks in advance

krishna


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 17, 2007 5:22 am 
Regular
Regular

Joined: Tue Jan 03, 2006 9:20 am
Posts: 74
use a separate hibernate sessionfactory for each database.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 18, 2007 1:03 am 
Newbie

Joined: Fri Nov 16, 2007 3:05 pm
Posts: 14
jwenting wrote:
use a separate hibernate sessionfactory for each database.


Hi

Thanks for the reply.

The main problem i face in my application is, since i create the database dynamically through my application , i will not be knowing how many database i will be having in my application. So i will not be able to create sessionfactory configuration for every database before itself.

what i understood from your reply is, i should either create a new hibernate.cfg.xml file(with different name) or alter the same hibernate.cfg.xml file by appending the new sessionfactory configuration , when ever i create a new database through my application.

So in this way i will be able get connected to the database, that is created through my application, using this sessionfactory configurations.

Is this what you are trying to convey me.

with thanks

krishna


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 18, 2007 9:55 am 
Beginner
Beginner

Joined: Mon Feb 19, 2007 4:22 am
Posts: 22
Location: Poland
As far as I know, you can create new Configuration (responsible for creating your SessionFactory later) without having to create hibernate.cfg.xml file. Look at the api for org.hibernate.cfg.Configuration. There are a few methods that might be useful for you. Hibernate.cfg.xml is only one of the options. You can have more than one Configuration object, created dynamically as needed. This leads you straightforward to more than one SessionFactory.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.