Wendy Gibbons wrote:
God object
William P O'Sullivan wrote:
You should always put these values outside the application, outside of the war/ear also!
Joe Ess wrote:
Wendy Gibbons wrote:
God object
Wendy, I don't think you mean a god object. That's an antipattern (a bad idea) where one puts all their functionality in One Big Object.
We have solved this problem a couple of different ways. The simplest is to extend java.util.Properties to append the user name or host name to the property that one asks for. The default case is the name of the property. So your property file looks like:
If one logs in to a system as test_user (which would presumably only happen on the test server), they'd get a database server name as "some_test_host" and a port of 5678. If one logs in as production_user, they'd get "some_production_host" and 9012. Any other user would get the default values of "localhost" and 1234 (in our case, the default is our development workstations).
Of course, I do mostly web applications, so we use the container to manage our database settings and connection pool. The above example is used for other configuration information.
Joe Ess wrote:
Wendy Gibbons wrote:
God object
Wendy, I don't think you mean a god object. That's an antipattern (a bad idea) where one puts all their functionality in One Big Object.
We have solved this problem a couple of different ways. The simplest is to extend java.util.Properties to append the user name or host name to the property that one asks for. The default case is the name of the property. So your property file looks like:
If one logs in to a system as test_user (which would presumably only happen on the test server), they'd get a database server name as "some_test_host" and a port of 5678. If one logs in as production_user, they'd get "some_production_host" and 9012. Any other user would get the default values of "localhost" and 1234 (in our case, the default is our development workstations).
Of course, I do mostly web applications, so we use the container to manage our database settings and connection pool. The above example is used for other configuration information.
Nauman Hasan wrote:Just curious if you are writing a DB tool? Unless you are doing so I don't know of a good reason why your users would be exposed to the DB details...
The better approach would be to do a mapping between a logical name the user knows about for instance West-End-Branch to all the relevant DB details which you have mentioned above.
Hope this helps...
~Nauman
Wendy Gibbons wrote:
I would stick this in a config file which can be created in front of the users, and then connected to their database.
A previous employer used to do demos like this, and this was how it was done.
Be very very careful about database independance. Test your product against the customer database vendor before you go out there, you wouldnd't believe the vendor specific gotchas
Well THAT's new! Comfort me, reliable tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|