Tomcat docs advise following code for openning a dbcp connection: <% // Obtain our environment naming context Context initCtx = new InitialContext(); Context envCtx = (Context)initCtx.lookup("java:comp/env");
// Look up our data source DataSource ds = (DataSource)envCtx.lookup("jdbc/eplResrc"); %> However, the Tomcat docs do not say anything about closing initCtx. Does this need to be explicitly closed in developer code? Will not-closing-it create memory leaks? The reason i ask is because i came across example of closing context in that Wrox book, "Professional Apache Tomcat", as follows: initCtx.close(); // closed after conn is closed (see Wrox, p.327) -paul lomack