[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Same data souce multiple database

unnis do-not-reply at jboss.com
Mon May 19 05:25:12 EDT 2008


How can I connect to multiple databases using same datasource.

My requirement is , 
Based on the user profile I need to connect multiple databases. All of my databases will reside in same mysql server and is having same structure.I can't use multiple datasource and multiple connection pool, since the number of databses is more. So my plan is to have a single datasource and swich the database using setCatalog() jdbc method.

My application does the data source lookup in the following ways

1) Direct JNDI lookup in EJB
2) Using Hibernate
3) Using KODO-JDO

In all the above cases I am using same JNDI name ( mySqlDS) .

How can I achive this ???

I feel that database switching has to be done before giving the connection to the client ( EJB/Hibernate/jdo) . So this has to be done at DataSource level so that ds.getConnection() should return the proper connection with proper catalog set.


If I am using CustomDataSource , Inside CustomDataSource is there a way to access values from EJbContext ???

Thanks & Regards

unnis

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4151693#4151693

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4151693



More information about the jboss-user mailing list