I close Context right after I get DataSource. Then I can still do
dataSource.getConnection(). So this close will not connection.
-----Original Message-----
From: Paul [mailto:paul@msci.ca]
Sent: September 12, 2003 2:19 PM
To: Tomcat Users List
Subject: 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
|