This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
While discussing about ServletContextListener, HFSJSP 2e says that it is used for initializing a DataSource. Is this a good approach? I've seen the DataSource objects are handled by the container itself. What is the best way?
My take on this is that it's a good way to do it because the datasource lookup only happens once. I've seen other code where the lookup happens over and over again which is a waste of resources. I've tried different ways of doing it and based on feedback that I received here, this is the context listener that I now use.
This is the DataSourceHolder class:
Suggestions for improving this are welcome.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson