Should I cache the java.sql.DataSource?
Yes!
While trying to brush up and plain Servlets and JSP, I was trying to improve on architecture and I happen to read the MySQL connector/J documentation. I was wondering if I should cache the DataSource or just create a call to JNDI everytime I invoke a database service on the application level.
/*
* Lookup the DataSource, which will be backed by a pool
* that the application server provides. DataSource instances
* are also a good candidate for caching as an instance
* variable, as JNDI lookups can be expensive as well.
*/