Connecting a Entity Bean to two different Data Bases.


EJB programming & troubleshooting: Connecting a Entity Bean to two different Data Bases.

  1. Is it possible to access two databases from two different venders i.e oracle,sybase from a single entity bean instance?Is it possible for both CMP & BMP ?If yes then how can we do that ?
  2. It depends on what you meam. For CMP, you can generally control which database a particular EJB accesses through configuration. It is usually an easy matter to switch from one supported database to another.

    If you mean an Entity Bean that can access two different databases at the same time, I don't know of any EJB vendors that support this for CMP. You can do it for BMP, but you would have to write the database management code yourself, and it would be very ugly.

    I also have a hard time imagining a situation where this would be useful. Are you likely to have one system that accesses the exact same data in two different database at the same time. Odds are good that the data will be different, and it would be easier to write two separate Entities to manage the data. Even if the data was exactly the same, it would be unlikely to stay that way, and again two Entities would be better.
  3. Depends[ Go to top ]

    hi friend .,

      For BMP the programmer must write the code to connect .. but for CMP possibly we cannot .

     regards ,,

      krishna kishore
  4. use cocobase[ Go to top ]

    use cocobase :)
  5. I'm looking into the same issue, here I want to develope one application source and descriptors which can connect t multiple database types, especially Oracle and MS SQL Server.

    For example Oracle discourages the use of it' INTEGER, SMALLINT etc. types in favor of the NUMERIC with set scale and precision, these are all translated into java.lang.BigDecimal.