Meaningless Drivel is fun!
The moose likes EJB and other Java EE Technologies and the fly likes CMP db Access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "CMP db Access" Watch "CMP db Access" New topic

CMP db Access

Bernhard Neuhauser

Joined: Feb 06, 2006
Posts: 21
Hi again,

Is it possible to access more then one DB via CMP inside the same EJB container?

Maybe another issue:
Is it possible to cache some Entities readonly for failsavety reasons?

Currently i search for a possibility to hold some tables as local cache being accessible for all Cliens. When the db disapears, this might give me the possibility to server clients till the db failover is completed.

I know that several ejb calls will fail, because they need write access. But i also know that my app might be able to serve some client types without the db.

So for example a small outdated h2 in-memory db will be already enough for my purpose. But i dont know if its possible to share this db with all connected clients.

thx for feedback
Bernhard Neuhauser
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
Your CMP *layer* can use multiple databases, but any one CMP *bean* can only use a single database. Having read-only beans could possibly protect you from short outages if the *only* usages during that time period are read-only (i.e. no change events progated from a read/write version of the same bean), but only until you hit whatever refresh event your read-only beans have been configured to implement. If you need transparent failover, you might want to look into databases that provide transparent failover with a JDBC driver supporting that feature (e.g. Oracle RAC).
[ February 15, 2006: Message edited by: Reid M. Pinchback ]

Reid - SCJP2 (April 2002)
Bernhard Neuhauser

Joined: Feb 06, 2006
Posts: 21
thx ) exactly what i wanted to know

The db behind is already clustered. Still, there might be some "circumstances" where the db will be unavailable for some minutes. The own appserver will still try to serve some clients.

The fallback cmps are readonly in this case. Okay there will be updates from another app, but i think im able to trigger the refresh event when an update occours.

I agree. Here's the link:
subject: CMP db Access
It's not a secret anymore!