tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phillip Qin <>
Subject RE: dbcp, initCtx.close()??
Date Fri, 12 Sep 2003 18:20:02 GMT
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 [] 
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

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