tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul" <>
Subject dbcp, initCtx.close()??
Date Fri, 12 Sep 2003 18:18:46 GMT
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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message