It's hard to give a definitive answer w/out knowing your environment, but this often comes up in a webserver environment. If that is your case you are lucky since most webservers provide a JNDI-lookup capability, and built-in or third-party resource pooling be it
JDBC connections, Mail sessions, or whatever.
It may not be useful to launch into too much detail, but in a
Tomcat environment you can define a resource and then access it via a JNDI-lookup in the application (
Servlet, bean,
JSP, etc.)
If you provide a little more information about your runtime environment someone can give you a more detailed answer.