• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Dynamically connection to multiple databases from single J2ee Application

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear sirs,

I have a J2ee application which is running in JBOSS Server. The Data tier is MySql. We are using CMP
Now the scenario is like this,
We are having two clients, and the clients have different sub users. The clients are using two seperate database for the same application. Now the application is working in two different servers assigned for each clients. Now we are planning to integrate it to a single application . I would like to know whether
1. Is it possible to specify the JNDI names for more than one database in the deployement descriptor?
2. if it is then, how can we instruct the container to lookup dynamically for the appropriate database based on the user logged in to the application .
I am planning to setup a new DB for the users information sothat the container can select the appropriate DB based on the user logged in...

Thankyou,
Sudheesh K S,
 
author & internet detective
Posts: 41502
881
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sudheesh,
You can't have the same CMP point to different databases at the same time. Why not deploy the application twice and have each user point to a different one?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing this problem now and have a solution for this...

same CMP class can be used but deployed with different ejb-name/jndi-name/datasource

so if u have 2 clients to support, the class remains same, but the deployment descriptors deploy the same CMP with 2 different names, 2 diff JNDI.. & they have different datasources...
Now in your code, u have the client info, which can be used to lookup the appropriate JNDI name.. (the jndi-name has a prefix of client name, which can be used during lookup..)

If you can write the DD by hand, well & gud.. because none of existing EJB doclet probably support such feature... i wud be writing a doclet for my code soon, as the number of CMPs is 100+ ..

I would like to have more suggestions on same from experts..

-thnx
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic