X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id BFEBE11F61DE for ; Fri, 28 Apr 2006 02:57:09 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 95748-01 for ; Fri, 28 Apr 2006 02:56:58 -0300 (ADT) X-Greylist: delayed 00:28:20.758453 by SQLgrey- Received: from chrobd01.vailsys.com (chrobd01.vailsys.com [63.210.102.138]) by postgresql.org (Postfix) with ESMTP id E690D11F6002 for ; Fri, 28 Apr 2006 02:56:57 -0300 (ADT) Received: from dfsfbd06.vail (dfsfbd06.vail [192.168.129.190]) by chrobd01.vailsys.com (Postfix) with ESMTP id 3AF904985; Fri, 28 Apr 2006 00:28:32 -0500 (CDT) Received: from [192.168.34.12] (unknown [192.168.34.12]) by dfsfbd06.vail (Postfix) with ESMTP id 1332E3240BE; Fri, 28 Apr 2006 00:28:32 -0500 (CDT) Message-ID: <4451A813.6030403@vailsys.com> Date: Fri, 28 Apr 2006 00:28:51 -0500 From: David Durham User-Agent: Thunderbird 1.4 (Windows/20050908) MIME-Version: 1.0 To: "J." Cc: pgsql-jdbc@postgresql.org Subject: Re: connection pooling with servlets References: <20060428005915.94720.qmail@web54213.mail.yahoo.com> In-Reply-To: <20060428005915.94720.qmail@web54213.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/180 X-Sequence-Number: 15114 J. wrote: > Thanks for replying. I'm not sure if that would help, but maybe if I > understand the suggestion better it will. > > Right now I've got the index.jsp calling Login servlet via POST. Then > Login creates the connection, puts it into a session with some other > attributes and forward(req,res) to welcome.jsp. Not much point in storing a datasource as a session attribute (1 datasource per application user?). More appropriate to make it application-wide by putting a datasource in a servlet context or, as someone else suggested, a static attribute/property/member/variable ... request.getSession().getServletContext().setAttribute(...). JNDI is another good place to put this sort of thing. An easy way to make sure your datasource is always available is to use a servlet context listener to create it when the application is initialized. Google for servlet context lifecycle should tell you how to do setup a listener. Now, as for a null pointer on your connection object, maybe you have something misconfigured in your datasource. Username, password, host, and driver class are usual suspects. > Welcome.jsp has a form > that uses GET to call a Search servlet and this is where I get a null > pointer on the connection object. I'm trying to get the session out of > the request object, but it seems like the request loses state by the > time I'm getting to it (in Search servlet). Not sure. You can post your code and maybe get some help. Wait, is this homework? -Dave