Does anyone know if it's possible to have an app server dynamically configure itself to use different databases at runtime? I'm using CMP with JBOSS, and the databases I'd like to use for my application are identical in structure except they contain different data.
thanks.
-
multiple databases + one j2ee server (2 messages)
- Posted by: Daniel Labrosse
- Posted on: June 26 2001 06:51 EDT
Threaded Messages (2)
- multiple databases + one j2ee server by Jason McKerr on June 26 2001 11:45 EDT
- multiple databases + one j2ee server by Aditya Anand on June 26 2001 14:15 EDT
-
multiple databases + one j2ee server[ Go to top ]
- Posted by: Jason McKerr
- Posted on: June 26 2001 11:45 EDT
- in response to Daniel Labrosse
Sure, I often use a fairly simple factory pattern to "let the system know" what database to use at run time.
I think that the Pet Store from java.sun.com has a sample of this, but I don't remember, and I know they've changed it since the last time I looked at it.
You might take a look at pet store though. Some of the stuff in their factory patterns is sometimes a little overcomplicated when your trying to do something relatively simple. It's kind of like swatting a fly with a buick, so you might want to simplify some of it.
I've also done some of this with JBoss, although only with BMP, but it should work fine for you. You might consider combining the pattern with the minerva connection pool system.
-Newt -
multiple databases + one j2ee server[ Go to top ]
- Posted by: Aditya Anand
- Posted on: June 26 2001 14:15 EDT
- in response to Daniel Labrosse
you need to register both data bases as 2 different data sources.. have an environment variable or bind the datasource name you wish to use to a wellknown registry entry... this would allow you to switch data bases.... but if you want to switch databases per request... use the factory pattern as suggested by Jason above