• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

ejb using datasource best practice

Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we have some stateless session beans that use a DataSource to do some db stuff. there's one static class DatabaseManager, which is used by all the beans and basically "manages" the use of a data source (provides convenience methods i guess). the beans initialize this database manager by getting some strings from their env-entries, DataSourceURL, DataSourceJNDIName, InitialContextFactory. the DatabaseManager then gets the datasource using the provided information.

this completely sidesteps the use of a resource-ref by the beans. and i see quite a few issues regarding this practice. i'd like to hear what some of the other ranchers think.

the bean's env-entry is hardwired to a specific url/connection factory for getting to a datasource. the dd needs to be reconfigured if the bean is going to be put into a container that is on a different port.

i'm also concerned that our container will give out a datasource when doing a remote lookup like this. maybe it's configurable to not allow this activity, but it seems to be that any client application could do a lookup on the server and get a datasource and effectively have open access to the database? i haven't tried yet to bring up a runnign server, and try with a separate client application to get a datasource from the server the same way the beans do, but that's on my list.

if anyone has any comments/thoughts on this it would certainly be most appreciated.
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic