EJB - Dynamic data source binding

608 Views Asked by At

We are trying to implement Model-2 SaaS to our application.

(Please refer IBM Link for what is Model-2.)

Model-2 is having separate database schema per customer with one EAR (Application).

Schema and data source will be dynamic based on login customer (Tenant)

But in our application. We have EJBs (Mostly State Less Session beans).

Data source name is mapped in ejb-jar.xml for each session bean like below.

<resource-ref>
    <description>No Description</description>
    <res-ref-name>jdbc/DB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

But this way it is not possible to achieve Model-2 of SaaS. Is there any way to dynamically bind data source for EJBs or any work around solution, please suggest? For customer-1, it should be jdbc/DB1, for customer-2 it should be jdbc/DB2...etc.

I have searched for similar problems, but I wanted a solution with in EJB, instead of changing the technology, please suggest.

Thanks in advance

Change Data source Dynamic Data Source Routing

0

There are 0 best solutions below