This the only thing I've done so far:
public static void setDataSource(
String name) throws NamingException {
Context context = new InitialContext();
context = (Context)context.lookup("java:/env/com/env");
dataSource = (DataSource)context.lookup(name);
}
I keep the datasource around in a singleton class and fetch a connection when necessary in various places in my webapp. I have yet to do this so there are no connections requested by me. But since there's a pool of connections created by tomcat's DBCP tomcat should take care of releasing them when it shuts down.