• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic