Each of your Java 2 platform, Enterprise Edition (J2EE) applications (in an EAR
file) can have more than one enterprise bean container-managed persistence (CMP) module in it. Each EJB CMP module (as a JAR file) can contain more than one CMP bean.
You can configure each bean to connect to its own data source by using the different Java Naming and Directory Interface (JNDI) names of each data source. However, there are some constraints:
The deployment tool only enables you to map EJB CMP beans to different databases at the EJB JAR level. There are different back-end IDs for different database schema mapping. The product uses the attribute backendId to distinguish database specific code. For example, the code that accesses an Oracle database is different from that accessing a DB2 database. Even for the same vendor, different versions of their products can result in different generated code.
At run time, WebSphere Application Server uses the CurrentBackendId attribute to access the correct back-end related code. You can only configure the CurrentBackendId at the EJB JAR level. This means that all of the EJB CMP beans within a specific EJB JAR file (which contains all the CMR
beans) must connect to the same type of data source (that is, the same vendor,
same version).
Even though you can connect EJB CMP beans to different databases of the same type, the process fails if your connections result in a table join between tables from different databases. Various actions such as EJB
Query , Inheritance support, readAhead.., and so on, can result in a table join situation.
The datasource needs to be an XA datasource to support multiple databases'
connection within a transaction.