Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / November 2004

Tip: Looking for answers? Try searching our database.

Hibernate and multiple datasources...

Thread view: 
Lionel - 15 Oct 2004 10:05 GMT
Hi !!!

I have an hibernate application thta as multiple databases.
Depending on the country of the user, I will access the database of his
country.
All databases have exactly the same structure.
How can I manage this with struts/hibernate ?

Here is the solution I think I will use:
- define a JNDI datasource for each database.
- create an hibernate.cfg.xml for each database, using the same hbm files,
load in context each SessionFactory
- use a ServletFilter to open a connexion to the correct database depending
on the user profile for each http request

Do you see any problem in this configuration ?
Could I do better ?

Thanks.
Kingsley Idehen - 15 Oct 2004 18:18 GMT
10/15/2004 5:05:33 AM
Lionel <> wrote in message
<416f92db$0$563$626a14ce@news.free.fr>

> Hi !!!
>
[quoted text clipped - 15 lines]
>
> Thanks.
What about simply creating one JDBC DSN that connects you to all the
different databases? If you want to investigate this approach then
take a look at OpenLink Virtuoso at: http://virtuoso.openlinksw.com .
It allows you to make one JDBC connection to several ODBC or JDBC
Data Sources that are bound to a variety of backend databases.
Alternatively, you can have Hibernate simply bind to one data source,
since Virtuoso can produce Well-Formed and/or Valid XML data (that is
accessible via HTTP/WebDAV) from heterogeneous ODBC or JDBC data
sources on the Fly (using; SQLX, SQL-XML, XML-SQL Schema Mapping).
So you can give Hibernate a DSN or a URI to an XML doc, in both cases
the underlying heterogeneous data sources are unified without you
writing code to handle the complexity of this effort.

Regards,

Kingsley Idehen   Weblog: http://www.openlinksw.com/blog/~kidehen
OpenLink Software        Web: http://www.openlinksw.com
Universal Data Access & Universal Integration Middleware Providers.
Boris Cinkler - 29 Nov 2004 05:09 GMT
There should be a way to pass java.sql.Connection to Hibernate when
openning session, and it will use that connection instead.

PS I didn't work with Hibernate 2.0 and 2.1, there may be actually
better way to do that.

Boris

> Hi !!!
>
[quoted text clipped - 15 lines]
>
> Thanks.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.