• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swapping database runtime  RSS feed

 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have received a request to "do some magic to make the application able to swap between databases runtime".

Is this at all possible? Database is specified by the deployment descriptor, and as I understand it the deployment descriptor needs to be changed in this case - and thus a redeployment is required.

Using WebSphere 5.0 (possibility of 5.1), EJB 2.0 spec, cmp EntityEJBs, stateless session EJBs.
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if there is any solution.
Having said that going through a JMX tutorial or book may help to find out
if there is any solution to this.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "ckarthi"-

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it - please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by �dne Brunborg:
I have received a request to "do some magic to make the application able to swap between databases runtime".


Not easy in EJB; it just doesn't think that way. You can approximate it, but frankly it isn't worth the effort. The problem is that you can't do it in the middle of a transaction, so you have to have a way of doing it between transactions - except in a live system, there are many transactions in play at any instant in time.

The only decent way I know of to do this would only be possible where you have strongly-divided layers in your architecture. For example, in your web layer you could have a session or application-scope control that is used by your JSP pages or MVC framework to control which EJB back-end it wanted to talk to. You could deploy 2 or more copies of your EJB layer, each pointing at a different database. This works provided that your web layer doesn't try to maintain or simulate an open transaction across invocations.

Besides, if you think about this, this is potentially the most evil thing in the J2EE universe. You write a bit of data, it commits, you try to read the database back again and it isn't there. Why? Because your wrote to one database and read from another. Ick.

If somebody is just worried about databases going down, the solution is to look at something like Oracle RAC. Weblogic, for example, has JDBC drivers that support Oracle RAC.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!