tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: JNDI DataSource - need to synchronize?
Date Mon, 08 Sep 2003 13:16:12 GMT

You don't need to synchronize pool access for DBCP at the calling
application level (which is your level).  You also don't need to keep a
reference to the initial or lookup context, just the datasource.  Make
sure to clean and null out the datasource reference in your servlet's
destroy() method.

Yoav Shapira
Millennium ChemInformatics

>-----Original Message-----
>From: Marco Tedone []
>Sent: Sunday, September 07, 2003 4:13 AM
>To: Tomcat Users List
>Subject: Re: JNDI DataSource - need to synchronize?
>Well, to be sure, put your variables inside the methods. This way, your
>will be safe. One idea would be to create objects when you need them,
>close them when you've finished.
>----- Original Message -----
>From: "john-paul delaney" <>
>To: "Tomcat Users List" <>
>Sent: Sunday, September 07, 2003 12:18 PM
>Subject: JNDI DataSource - need to synchronize?
>> Hello List...
>> Some coding help please.  Following earlier advice on this list and
>datasource how-to, I've now got a working test servlet.  Basically I
>the Context(s) and DataSource as instance variables, and initialize
them in
>> ========================================================
>>    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
>closes it's own connection, will it affect the Context or DataSource
>of this request?
>> Thanks for any clarification,
>> /j-p.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
>To unsubscribe, e-mail:
>For additional commands, e-mail:

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

View raw message