You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Paul <pa...@msci.ca> on 2003/09/12 20:18:46 UTC
dbcp, initCtx.close()??
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