Forums Register Login

ejb using datasource best practice

+Pie Number of slices to send: Send
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.
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 726 times.
Similar Threads
DataSource via JNDI in WSAD 5
Distributed EJB lookup problem
database access outside of servlet container
Sharing ServletContext
lookup(java:comp
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 00:47:06.