Return-Path: Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 2925 invoked from network); 7 Sep 2003 08:06:27 -0000 Received: from unknown (HELO angelico.justatest.com) (213.155.200.208) by daedalus.apache.org with SMTP; 7 Sep 2003 08:06:27 -0000 Received: from angelico.justatest.com (angelico.justatest.com [192.168.1.2]) by angelico.justatest.com (8.12.8/8.12.8) with ESMTP id h87BIpni012269 for ; Sun, 7 Sep 2003 10:18:52 -0100 Date: Sun, 7 Sep 2003 10:18:51 -0100 (GMT+1) From: john-paul delaney To: Tomcat Users List Subject: JNDI DataSource - need to synchronize? Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hello List... Some coding help please. Following earlier advice on this list and the TC datasource how-to, I've now got a working test servlet. Basically I declare the Context(s) and DataSource as instance variables, and initialize them in init: ======================================================== Context initContext = null; Context envContext = null; DataSource ds = null; public void init() throws ServletException { try { initContext = new InitialContext(); envContext = (Context) initContext.lookup( "java:comp/env"); ds = (DataSource) envContext.lookup( "jdbc/jpdb"); } catch (NamingException e) { throw new ServletException( "Couldn't setup JNDI Context/DataSource", e); } } ========================================================== If this is the correct approach, should I be synchronizing the Context(s)/DataSource in the doGet method? If another http request thread closes it's own connection, will it affect the Context or DataSource object of this request? Thanks for any clarification, /j-p.