-
1. Re: Same data souce multiple database
peterj May 19, 2008 11:27 AM (in response to unnis)I haven't tried this, but here is what I would do.
First, set up only one *-ds.xml file connected to one of the MySQL databases. I would also make sure that the user-name and password has rights to all of the MySQL databases. Then have the apps initially connect to the database defined by the *-ds.xml file, and then issue the "use XXX" statement to switch databases. -
2. Re: Same data souce multiple database
unnis May 20, 2008 12:58 AM (in response to unnis)I can also do the same thing if my application takes the database connection using ds.getConnection()
But in my case I am using Hibernate and kodo-jdo. Both cases i need a managed connection, so I am using the same -ds file for this. Finally all connections will come from same connection pool.
Since Hibernate and Kodo-jdo takes the connection using datasource look up in their own code, I won't be able to change the database there. So this has to managed in the datasource level. -
3. Re: Same data souce multiple database
jaikiran May 20, 2008 1:57 AM (in response to unnis)"unnis" wrote:
Since Hibernate and Kodo-jdo takes the connection using datasource look up in their own code, I won't be able to change the database there. So this has to managed in the datasource level.
From what i know, Hibernate allows the schema to be set through one of its APIs.Configuration cfg = new Configuration(); cfg.setProperty("hibernate.default_schema", "XXX"); SessionFactory sf = cfg.configure().buildSessionFactory();
-
4. Re: Same data souce multiple database
unnis May 20, 2008 2:32 AM (in response to unnis)From what i know, Hibernate allows the schema to be set through one of its APIs.
Yes hibernate allows it. But I need to create seperate sessionfactiories for each database. Since number of database is more , this may not be good solution . And if somebody gets the connection from hibernate session and use that connection for JDBC query , it will use the default catalog which is set in the ds.xml -
5. Re: Same data souce multiple database
jaikiran May 20, 2008 3:11 AM (in response to unnis)"unnis" wrote:
But I need to create seperate sessionfactiories for each database. Since number of database is more , this may not be good solution .
In-fact that's a correct thing to do http://www.hibernate.org/117.html#A23